pymysql DAO简单封装
#!/usr/bin/env python # -*-coding:utf-8 -*- # # 无法执行多个query,self.conn.close()放在CdbConn类的单独函数中,每次query之后要手动close;否则多次query,会自动关闭 import pymysql class CdbConn (): def __init__ ( self , db_host , db_user , db_pwd , db_name , db_port = 3306 ): self . db_host = db_host self . db_port = db_port self . db_user = db_user self . db_pwd = db_pwd self . db_name = db_name self . status = True self . conn = self . getConnection () def getConnection ( self ): try : conn = pymysql . Connect ( host = self . db_host , # 设置MYSQL地址 port = int ( self . db_port ), # 设置端口号 user = self . db_user , # 设置用户名 passwd =