MySQLdb 操作数据库
Conn_IP = ""
Conn_UserName = ""
Conn_PassWord = ""
Conn_database = ""
conn = MySQLdb.connect(Conn_IP,Conn_UserName,Conn_PassWord,Conn_database)
cursor = conn.cursor()
val = {"k1":t,"k2":n}
ins_sql = "insert into 表(字段1,字段2) values(%(k1)s,%(k2)s)"
try:
cursor.execute(ins_sql,val)
conn.commit()
except:
conn.rollback()
conn.close()