本文整理汇总了Python中migrate.versioning.api.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createdb
def createdb():
""" Creates a database with all of the tables defined in
the SQLAlchemy models. Creates and initializes an
SQLAlchemy-migrate repository if none exists.
"""
# Create New DB Reflecting SQLAlchemy Data Models
db.create_all(app=app)
admin = User('admin', '/home/admin', 'password')
db.session.add(admin)
db.session.commit()
# Create SQLAlchemy-migrate Versioning Repository If Absent
if not os.path.exists(app.config['SQLALCHEMY_MIGRATE_REPO']):
api.create(app.config['SQLALCHEMY_MIGRATE_REPO'],
'database repository')
api.version_control(app.config['SQLALCHEMY_DATABASE_URI'],
app.config['SQLALCHEMY_MIGRATE_REPO'])
print "SQLAlchemy-migrate Versioning Repository Created in: " +\
app.config['SQLALCHEMY_MIGRATE_REPO']
else:
api.version_control(app.config['SQLALCHEMY_DATABASE_URI'],
app.config['SQLALCHEMY_MIGRATE_REPO'],
api.version(
app.config['SQLALCHEMY_MIGRATE_REPO']))
print "Database created in: " + app.config['SQLALCHEMY_DATABASE_URI']
示例2: run
def run(self):
db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
示例3: create_database
def create_database():
db.create_all()
if not os.path.exists(c.SQLALCHEMY_MIGRATE_REPO):
api.create(c.SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO, api.version(c.SQLALCHEMY_MIGRATE_REPO))
示例4: initialize_startup
def initialize_startup():
""" Force DB tables create, in case no data is already found."""
is_db_empty = False
session = SA_SESSIONMAKER()
inspector = reflection.Inspector.from_engine(session.connection())
if len(inspector.get_table_names()) < 1:
LOGGER.debug("Database access exception, maybe DB is empty")
is_db_empty = True
session.close()
if is_db_empty:
LOGGER.info("Initializing Database")
if os.path.exists(cfg.DB_VERSIONING_REPO):
shutil.rmtree(cfg.DB_VERSIONING_REPO)
migratesqlapi.create(cfg.DB_VERSIONING_REPO, os.path.split(cfg.DB_VERSIONING_REPO)[1])
_update_sql_scripts()
migratesqlapi.version_control(cfg.DB_URL, cfg.DB_VERSIONING_REPO, version=cfg.DB_CURRENT_VERSION)
session = SA_SESSIONMAKER()
model.Base.metadata.create_all(bind=session.connection())
session.commit()
session.close()
LOGGER.info("Database Default Tables created successfully!")
else:
_update_sql_scripts()
migratesqlapi.upgrade(cfg.DB_URL, cfg.DB_VERSIONING_REPO, version=cfg.DB_CURRENT_VERSION)
LOGGER.info("Database already has some data, will not be re-created!")
return is_db_empty
示例5: create_db
def create_db():
Base.metadata.create_all(engine)
if not path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
M1A = Module(name=u'M1A', slot=1, gpio=8, io_type='input', rpull=False, status=False, device_id='')
M1B = Module(name=u'M1B', slot=1, gpio=7, io_type='input', rpull=False, status=False, device_id='')
M1C = Module(name=u'M1C', slot=1, gpio=11, io_type='input', rpull=False, status=False, device_id='')
M2A = Module(name=u'M2A', slot=2, gpio=9, io_type='input', rpull=False, status=False, device_id='')
M2B = Module(name=u'M2B', slot=2, gpio=10, io_type='input', rpull=False, status=False, device_id='')
M2C = Module(name=u'M2C', slot=2, gpio=5, io_type='input', rpull=False, status=False, device_id='')
M3A = Module(name=u'M3A', slot=3, gpio=6, io_type='input', rpull=False, status=False, device_id='')
M3B = Module(name=u'M3B', slot=3, gpio=12, io_type='input', rpull=False, status=False, device_id='')
M3C = Module(name=u'M3C', slot=3, gpio=13, io_type='input', rpull=False, status=False, device_id='')
M4A = Module(name=u'M4A', slot=4, gpio=0, io_type='input', rpull=False, status=False, device_id='')
M4B = Module(name=u'M4B', slot=4, gpio=1, io_type='input', rpull=False, status=False, device_id='')
M4C = Module(name=u'M4C', slot=4, gpio=16, io_type='input', rpull=False, status=False, device_id='')
M5A = Module(name=u'M5A', slot=5, gpio=17, io_type='input', rpull=False, status=False, device_id='')
M5B = Module(name=u'M5B', slot=5, gpio=18, io_type='input', rpull=False, status=False, device_id='')
M5C = Module(name=u'M5C', slot=5, gpio=19, io_type='input', rpull=False, status=False, device_id='')
M6A = Module(name=u'M6A', slot=6, gpio=20, io_type='input', rpull=False, status=False, device_id='')
M6B = Module(name=u'M6B', slot=6, gpio=21, io_type='input', rpull=False, status=False, device_id='')
M6C = Module(name=u'M6C', slot=6, gpio=22, io_type='input', rpull=False, status=False, device_id='')
M7A = Module(name=u'M7A', slot=7, gpio=23, io_type='input', rpull=False, status=False, device_id='')
M7B = Module(name=u'M7B', slot=7, gpio=24, io_type='input', rpull=False, status=False, device_id='')
M7C = Module(name=u'M7C', slot=7, gpio=25, io_type='input', rpull=False, status=False, device_id='')
modules = [M1A, M1B, M1C, M2A, M2B, M2C, M3A, M3B, M3C, M4A, M4B, M4C,
M5A, M5B, M5C, M6A, M6B, M6C, M7A, M7B, M7C]
for m in modules:
session.add(m)
session.commit()
示例6: init_db
def init_db():
import models
Base.metadata.create_all(bind=engine)
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
示例7: create_db_and_update
def create_db_and_update(db_uri, migrate_repo):
if not os.path.exists(migrate_repo):
api.create(migrate_repo, 'database repository')
api.version_control(db_uri, migrate_repo)
else:
api.version_control(db_uri,
migrate_repo,
api.version(migrate_repo))
示例8: initdb
def initdb():
"""Creates all database tables."""
db.create_all()
if not os.path.exists(app.config.get('SQLALCHEMY_MIGRATE_REPO')):
api.create(app.config.get('SQLALCHEMY_MIGRATE_REPO'), 'database repository')
api.version_control(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'))
else:
api.version_control(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'), api.version(app.config.get('SQLALCHEMY_MIGRATE_REPO')))
示例9: __init__
def __init__(self):
database.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_CONT):
api.create(SQLALCHEMY_MIGRATE_CONT, "database container")
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_CONT)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_CONT, api.version(SQLALCHEMY_MIGRATE_CONT))
示例10: create
def create():
print '{} is being instantiated now!'.format(SQLALCHEMY_DATABASE_URI)
orm_db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
示例11: test_passing_engine
def test_passing_engine(self):
repo = self.tmp_repos()
api.create(repo, 'temp')
api.script('First Version', repo)
engine = construct_engine('sqlite:///:memory:')
api.version_control(engine, repo)
api.upgrade(engine, repo)
示例12: db_create
def db_create():
pgdb.create_all()
if not os.path.exists(Config.SQLALCHEMY_MIGRATE_REPO):
api.create(Config.SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(Config.SQLALCHEMY_DATABASE_URI, Config.SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(Config.SQLALCHEMY_DATABASE_URI, Config.SQLALCHEMY_MIGRATE_REPO, api.version(Config.SQLALCHEMY_MIGRATE_REPO))
示例13: create
def create():
create_engine(SQLALCHEMY_DATABASE_URI, echo=True)
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
api.version(SQLALCHEMY_MIGRATE_REPO))
示例14: CreateDB
def CreateDB():
print ("Creating DB")
db.create_all()
print ("Putting DB under version control")
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
示例15: create_db
def create_db():
from migrate.versioning import api
db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))