首页 > 数据库技术 > 详细

UI自动化web端框架mymysql.py代码

时间:2018-07-05 14:21:46      阅读:180      评论:0      收藏:0      [点我收藏+]
import pymysql
from lib.core.config import Config,ConfigType
class MyMysql(object):
def __init__(self):
self.config = Config()
self.data = self.config.read(ConfigType.MYSQL)
self.db = pymysql.connect(**self.data)
self.cur = self.db.cursor(cursor = pymysql.cursors.DictCursor)

def select_sql(self,sql):
try:
self.cur.execute(sql)
except Exception as e:
print(‘这里出错了,错误信息是:%s‘ % e)
else:
return self.cur.fetchone()

def other_sql(self,sql):
try:
self.cur.execute(sql)
except Exception as e:
print(‘这里出错了,错误信息是:%s‘ % e)
else:
self.db.commit()

def close(self):
self.cur.close()
self.db.close()

if __name__ == ‘__main__‘:
print(MyMysql().select_sql(‘select * from user_info;‘))

UI自动化web端框架mymysql.py代码

原文:https://www.cnblogs.com/laosun0204/p/9267999.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!