sql封装小例

import MySQLdb
def
executeSql(sql): print sql host = configOthers["sql_host"] port = int(configOthers["sql_port"]) user = configOthers["sql_user"] pwd = configOthers["sql_pwd"] db = configOthers["sql_db"] conn = MySQLdb.connect(host=host,port=port,user=user,passwd=pwd,db=db) cur = conn.cursor() cur.execute(sql) result = cur.fetchall() cur.close() conn.commit() conn.close() return result

 

posted @ 2019-03-11 07:45  xlfj1205  阅读(130)  评论(0编辑  收藏  举报