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