postgres_connector.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:flask_boilerplate 作者: minodes 项目源码 文件源码
def __init__(self, host, database, user, autocommit=True, pool=PostgresPool,
                 default_schema='public'):
        """
        Instantiate class from given SourceDb entry (one row in the datasource table)
        :param host:  Host address (domain or IP)
        :param database:    Name of the database
        :param user:      User
        """
        self.user = user
        self.hostname = host
        self.dbname = database

        # the password is taken from ~/.pgpass

        if self.dbname not in self.connection_pools:
            self.connection_pools[self.dbname] = pool(autocommit=autocommit,
                                                      minconn=1,
                                                      maxconn=5,
                                                      user=self.user,
                                                      host=self.hostname,
                                                      database=self.dbname,
                                                      default_schema=default_schema,
                                                      connect_timeout=config.DB_CONNECT_TIMEOUT)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号