db.py 文件源码

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

项目:yo 作者: steemit 项目源码 文件源码
def __init__(self, db_url=None):
        self.db_url = db_url
        self.url = make_url(self.db_url)
        if self.backend == 'postgres':
            self.loop = asyncio.get_event_loop()
            self.async_engine = self.loop.run_until_complete(
                create_engine(
                    user=self.url.username,
                    password=self.url.password,
                    host=self.url.host,
                    port=self.url.port,
                    database=self.url.database))
            self.engine = sa.create_engine(self.db_url)
        else:
            self.engine = sa.create_engine(self.db_url)
        self.metadata = metadata
        self.metadata.create_all(bind=self.engine)

    # db helper methods
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号