本文整理汇总了Python中models.create_tables函数的典型用法代码示例。如果您正苦于以下问题:Python create_tables函数的具体用法?Python create_tables怎么用?Python create_tables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_tables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_inserts
def test_process_inserts(self):
models.delete_tables()
models.create_tables()
new_playgrounds, revision_group = data.process_changes('tests/data/test_inserts.json')
self.assertEqual(len(new_playgrounds), 1)
playground = Playground.select().where(Playground.id == new_playgrounds[0].id)[0]
self.assertEqual(playground.name, 'NEW NAME')
revisions = Revision.select().where(Revision.revision_group == revision_group)
self.assertEqual(revisions.count(), 1)
revision = revisions[0]
self.assertEqual(revision.playground.id, playground.id)
log = revision.get_log()
self.assertEqual(len(log), 1)
self.assertEqual(log[0]['field'], 'name')
self.assertEqual(log[0]['from'], '')
self.assertEqual(log[0]['to'], 'NEW NAME')
headers = revision.get_headers()
self.assertEqual(headers['content_length'], '18')
self.assertEqual(headers['host'], 'localhost')
cookies = revision.get_cookies()
示例2: resetDB
def resetDB(self):
self.db.session.remove()
self.db.drop_all()
models.create_tables(self.app)
fixtures.install(self.app, *fixtures.all_data)
self.db = models.init_app(self.app)
示例3: __init__
def __init__(self):
"""
Initialize database connection and create tables.
"""
engine = db_connect()
create_tables(engine)
self.Session = sessionmaker(bind=engine)
示例4: bootstrap
def bootstrap():
with settings(warn_only=True):
local("dropdb breaking")
local("createdb breaking")
models.create_tables()
data.load_test_event()
data.load_test_facts()
示例5: __init__
def __init__(self):
"""
Initializes database connection and sessionmaker.
Creates tables.
"""
self.engine = db_connect()
create_tables(self.engine)
self.Session = sessionmaker(bind=self.engine)
示例6: create
def create(options, *args, **kwargs):
''' Creates/bootstraps the database '''
from libs.ConfigManager import ConfigManager # Sets up logging
from models import create_tables, boot_strap
print(INFO+'%s : Creating the database ...' % current_time())
create_tables()
print(INFO+'%s : Bootstrapping the database ...' % current_time())
boot_strap()
示例7: __dbinit__
def __dbinit__(self):
''' Initializes the SQLite database '''
logging.info("Initializing SQLite db ...")
if not os.path.exists(DBFILE_NAME):
logging.info("Creating SQLite tables")
dbConn = sqlite3.connect(DBFILE_NAME)
dbConn.close()
create_tables()
示例8: __init__
def __init__(self):
"""
Initializes database connection and sessionmaker.
Creates nfl_rosters_2015 table.
"""
engine = db_connect()
create_tables(engine)
self.Session = sessionmaker(bind=engine)
示例9: setUp
def setUp(self):
self.app = mvp.create_app('./settings/test.cfg')
models.create_tables(self.app.engine)
Session = sessionmaker(bind=self.app.engine)
self.db = Session()
示例10: __init__
def __init__(self):
'''
initializes the database connections and sessionmaker
creates all tables
'''
engine = db_connect()
create_tables(engine)
self.Session = sessionmaker(bind=engine)
示例11: on_novo_menu_item_activate
def on_novo_menu_item_activate(self, widget):
self.file_chooser.set_action(Gtk.FileChooserAction.SAVE)
response = self.file_chooser.run()
if response == Gtk.ResponseType.OK:
self.filename = self.file_chooser.get_filename()
models.init(self.filename)
models.open()
models.create_tables()
self.file_chooser.hide()
示例12: create
def create():
""" Creates/bootstraps the database """
from libs.ConfigManager import ConfigManager # Sets up logging
from models import create_tables, boot_strap
print(INFO + "%s : Creating the database ... " % current_time())
create_tables()
if len(argv) == 3 and (argv[2] == "bootstrap" or argv[2] == "-b"):
print("\n\n\n" + INFO + "%s : Bootstrapping the database ... \n" % current_time())
boot_strap()
示例13: create
def create():
''' Creates/bootstraps the database '''
from libs.ConfigManager import ConfigManager # Sets up logging
from models import create_tables, boot_strap
print(INFO+'%s : Creating the database ...' % current_time())
create_tables()
print(INFO+'%s : Bootstrapping the database ...' % current_time())
try:
boot_strap()
except:
print(WARN+"%s : Database has already been bootstrapped" % current_time())
示例14: __init__
def __init__(self):
"""Initializes database connection and sessionmaker
Create:
users table
reviews table
violations table
restaurants table
"""
engine = db_connect()
# engine.echo = True #prints out SQL we are loading
create_tables(engine)
self.Session = sessionmaker(bind=engine)
示例15: __init__
def __init__(self, url):
self.url = url
engine = db_connect()
try:
create_tables(engine)
except:
e = sys.exc_info()[0]
log.error("Unable to create tables. %s" % e)
self.Session = sessionmaker(bind=engine)
if not self.model:
log.warning("BaseStore instantiated without model class variable")
raise NotImplementedError("Subclasses must set model class!")