Пример #1
0
    def __init__(self,
                 host,
                 port,
                 user,
                 password,
                 dbname,
                 charset='utf8mb4',
                 beansdb=None,
                 autocommit=True,
                 report=lambda *args, **kwargs: None):

        super(MySQLDataBase, self).__init__(beansdb=beansdb,
                                            autocommit=autocommit,
                                            report=report)
        self.pool = Pool(
            lambda: get_conn(host, port, user, password, dbname, charset),
            conn_proxy_cls=MySQLConnProxy)
        self.modified_cursors = ThreadedObject(Queue)
Пример #2
0
    def __init__(self,
                 host,
                 port,
                 user,
                 password,
                 dbname,
                 charset='utf8mb4',
                 beansdb=None,
                 autocommit=True,
                 report=lambda *args, **kwargs: None,
                 pool_size=5,
                 pool_timeout=30,
                 pool_recycle=60 * 60,
                 pool_max_overflow=10):

        super().__init__(beansdb=beansdb, autocommit=autocommit, report=report)
        self.pool = Pool(
            lambda: create_conn(host, port, user, password, dbname, charset),
            conn_proxy_cls=PostgreSQLConnProxy,
            size=pool_size,
            timeout=pool_timeout,
            recycle=pool_recycle,
            max_overflow=pool_max_overflow,
        )