import configparser
import os
import sys
import pymysql
from DBUtils.PooledDB import PooledDB
import xlrd
mysql_host = ''
user = ''
password = ''
db = ''
port = 3306
class MysqlOperate(object):
def __init__(self):
self.pool = PooledDB(pymysql, 5, host=mysql_host, user=user, passwd=password, db=db, port=port) # 5为连接池里的最少连接数
self.db = self.pool.connection() # 以后每次需要数据库连接就是用connection()函数获取连接就好了
def excute_update(self, sql, params):
"""
主要负责数据update
:param sql: type: str sql语句
:param params: type: list sql字段
:return: None
"""
cur = self.db.cursor()
cur.execute(sql, params)
self.db.commit()
cur.close()
def excute_select(self, sql, params):
"""
主要负责数据select
:param sql: type: str sql语句
:param params: type: list sql字段
:return: None
"""
cur = self.db.cursor()
cur.execute(sql, params)
results = c
python 读取 excel 并根据 excel 的值 update mysql
最新推荐文章于 2024-08-12 03:53:33 发布