使用SQLAlchemy创建新数据库

http://sqlalchemy-utils.readthedocs.org/en/latest/database_helpers.html

from sqlalchemy import create_engine
from sqlalchemy_utils import database_exists, create_database

engine = create_engine("postgres://localhost/mydb")
if not database_exists(engine.url):
    create_database(engine.url)

print(database_exists(engine.url))

你可能感兴趣的:(使用SQLAlchemy创建新数据库)