import pymysql
from dbutils.pooled_db import PooledDB
from config import config
class DBHelper:
def __init__(self):
"""
:param mincached:连接池中空闲连接的初始数量
:param maxcached:连接池中空闲连接的最大数量
:param maxshared:共享连接的最大数量
:param maxconnections:创建连接池的最大数量
:param blocking:超过最大连接数量时候的表现,为True等待连接数量下降,为false直接报错处理
:param maxusage:单个连接的最大重复使用次数
:param setsession:optional list of SQL commands that may serve to prepare
the session, e.g. ["set datestyle to ...", "set time zone ..."]
:param reset:how connections should be reset when returned to the pool
(False or None to rollback transcations started with begin(),
True to always issue a rollback for safety's sake)
:param host:数据库ip地址
:param port:数据库端口
:param db:数据库名
:param user:用户名
:param passwd:密码
:param charset:字符编码
"""
mincached = 0
maxcached = 0
maxshared = 0
maxconnections = 0
blocking = True
maxusage = 0
setsession = None
reset = True
host = config.mysql_config["host"]
port = config.mysql_config["port"]
db = config.mysql_config["database"]
user = config.mysql_config["user"]
passwd = config.mysql_config["password"