def _init_connect(self): '初始化连接' try: self._conn = PooledDB.connect(**self._config) self._cursor = self._conn.cursor() except Exception as e: logging.error(e)
def _init_connect(self): """初始化连接""" try: self.__conn = PooledDB.connect(**self._config) self.__cursor = self.__conn.cursor() except Exception as e: logging.error(e) if self.__conn is None: raise ValueError("Failed to initialize connection.")
def __init__(self): # 初始化数据库连接 self.__config = dict({ "host": self.__host, "port": self.__port, "user": self.__user, "password": self.__password, "db": self.__db, "charset": self.__charset, "cursorclass": self.__cursorclass }) try: self.__conn = PooledDB.connect(creator=pymysql, **self.__config) self.__cursor = self.__conn.cursor() except pymysql.err.OperationalError as e: print("Mysql Error %d: %s" % (e.args[0], e.args[1]))
def __init_connect(self): '初始化连接' self.__conn = PooledDB.connect(**self.__config) self.__cursor = self.__conn.cursor()