Skip to content

Instantly share code, notes, and snippets.

@papachan
Created December 2, 2011 14:50
Show Gist options
  • Save papachan/1423502 to your computer and use it in GitHub Desktop.
Save papachan/1423502 to your computer and use it in GitHub Desktop.
import MySQLdb
sql = """INSERT INTO table ( value_1 , created_at , value_2 , text ) VALUES (%s,%s,%s,%s,%s)"""
if __name__ == "__main__":
db = MySQLdb.Connect(host="127.0.0.1", user="admin",passwd="",db="mysql_dbname")
c = db.cursor()
try :
c.execute(sql, ('value', '0000-00-00 00:00:00', 'value 2', 'my etxt'))
db.commit()
except:
db.rollback()
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment