renyupeng 2 年之前
父节点
当前提交
c3b4689d2d
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      utils/mysql_helper.py

+ 5 - 5
utils/mysql_helper.py

@@ -8,15 +8,17 @@ coding=utf-8
 @contact: renyupeng@c-top.com.cn
 @contact: renyupeng@c-top.com.cn
 @Tel 1501435553
 @Tel 1501435553
 """
 """
-import MySQLdb
+import pymysql
 import logging
 import logging
+
+from constant.ConfConstant import ConfConstant
 from utils.send_feishu_msg import SendFeiShuMsg
 from utils.send_feishu_msg import SendFeiShuMsg
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
 
 
 
 
 def insert(item, table_name):
 def insert(item, table_name):
-    con = MySQLdb.connect(host='192.168.0.184', user='hcst', passwd='hcst@2021', charset='utf8', port=3390)
+    con = pymysql.connect(host='192.168.0.184', user='hcst', passwd='hcst@2021', charset='utf8', port=3390)
     async_item = tuple(item.values())
     async_item = tuple(item.values())
     # 对数据库进行插入操作,并不需要commit,twisted会自动commit
     # 对数据库进行插入操作,并不需要commit,twisted会自动commit
     placeholders = ', '.join(['%s'] * len(item))
     placeholders = ', '.join(['%s'] * len(item))
@@ -35,7 +37,7 @@ def insert(item, table_name):
 
 
 
 
 def batch_insert(item_list, table_name):
 def batch_insert(item_list, table_name):
-    con = MySQLdb.connect(host='192.168.0.184', user='hcst', passwd='hcst@2021', charset='utf8', port=3390)
+    con = pymysql.connect(host='192.168.0.184', user='hcst', passwd='hcst@2021', charset='utf8', port=3390)
     # 对数据库进行插入操作,并不需要commit,twisted会自动commit
     # 对数据库进行插入操作,并不需要commit,twisted会自动commit
     placeholders = ', '.join(['%s'] * len(tuple(item_list[0])))
     placeholders = ', '.join(['%s'] * len(tuple(item_list[0])))
     columns = ', '.join(item_list[0].keys())
     columns = ', '.join(item_list[0].keys())
@@ -55,5 +57,3 @@ def batch_insert(item_list, table_name):
     con.close()
     con.close()
 
 
 
 
-class MysqlDBHelper:
-    """这个类也是读取settings中的配置,自行修改代码进行操作"""