#!/usr/bin/python
-- coding: UTF-8 --
import MySQLdb,re
class mysqlCmd(object)
: def mysqlclient_Insert(self, cmdlist, hostname=‘106.12.178.245’, port=3306, username=‘root’, password=’***’): ‘’’ 执行insert_sql语句 ‘’’ try : conn = MySQLdb.connect( host=hostname, port=port, user=username, passwd=password, db=‘test’, )
cur = conn.cursor()
for i in range(len(cmdlist)):
cur.execute(cmdlist[i])
b = cur.fetchall()
cur.close() conn.commit()
conn.close()
print ("%s" % b)
except :
cur.close()
conn.commit()
conn.close()
print (“BUG”)