we're using postgres, but sqlalchemy can connect to other things too.engine = create_engine('postgres://%s:%[email protected]/%s'%(username,mypassword,dbname))print"Connecting to",engine.urlifnotdatabase_exists(engine.url):create_database(engine.url)print"Does database exist?"...
database_exists('postgresql://postgres@localhost/name')#=>Falsecreate_database('postgresql://postgres@localhost/name')database_exists('postgresql://postgres@localhost/name')#=>True create_database create_database('postgresql://postgres@localhost/name') ...
需要先进行安装sqlalchemy_utils 安装:pip install sqlalchemy_utils 导入:from sqlalchemy_utils import create_database,database_exists
defupgrade(ver, session):ifverisNone:iftable_exists('episode_qualities', session): log.info('Series database format is too old to upgrade, dropping and recreating tables.')# Drop the deprecated datadrop_tables(['series','series_episodes','episode_qualities'], session)# Create new tables fro...
defupgrade(ver, session):ifverisNone:iftable_exists('episode_qualities', session): log.info('Series database format is too old to upgrade, dropping and recreating tables.')# Drop the deprecated datadrop_tables(['series','series_episodes','episode_qualities'], session)# Create new tables fro...