syncdb.py 文件源码

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

项目:websauna 作者: websauna 项目源码 文件源码
def main(argv: t.List[str]=sys.argv):
    """Create initial tables for the database specified on the configuration file.

    :param argv: Command line arguments, second one needs to be the uri to a configuration file.
    :raises sys.SystemExit:
    """
    if len(argv) < 2:
        usage_message(argv)

    config_uri = get_config_uri(argv)
    request = init_websauna(config_uri)

    with transaction.manager:
        engine = request.dbsession.get_bind()
        # Always enable UUID extension for PSQL
        # TODO: Convenience for now, because we assume UUIDs, but make this somehow configurable
        engine.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')

        Base.metadata.create_all(engine)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号