def mysqlConnectionSql(sql,value):
try:
conn=MySQLdb.connect(host='127.0.0.1',user='webuser',passwd='yzkj2014',db='cad',port=33070)
cur=conn.cursor()
cur.execute(sql,value)
conn.commit()
cur.close()
conn.close()
print "[Mysql Success] {0},{1}".format(sql,nowString())
except MySQLdb.Error,e:
print "[Mysql Error] {0}: {1}".format(e.args[0], e.args[1])
finally:
print "[Mysql end] {0},{1}".format(sql,nowString())
def nowString():
return '{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())