当前位置: 首页>>代码示例>>Python>>正文


Python models.create_tables函数代码示例

本文整理汇总了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()
开发者ID:imclab,项目名称:playgrounds2,代码行数:29,代码来源:test_data.py

示例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)
开发者ID:umworkma,项目名称:Comp4350,代码行数:7,代码来源:unit_tests.py

示例3: __init__

 def __init__(self):
     """
     Initialize database connection and create tables.
     """
     engine = db_connect()
     create_tables(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:mcwitt,项目名称:apt-hunter,代码行数:7,代码来源:pipelines.py

示例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()
开发者ID:nprapps,项目名称:breaking-news-facts,代码行数:8,代码来源:fabfile.py

示例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)
开发者ID:johnconnelly75,项目名称:newsCurator,代码行数:8,代码来源:pipelines.py

示例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()
开发者ID:lavalamp-,项目名称:RootTheBox,代码行数:8,代码来源:rootthebox.py

示例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()
开发者ID:moloch--,项目名称:BTSyncBot,代码行数:8,代码来源:BTSyncBot.py

示例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)
开发者ID:AncillaryStats,项目名称:AS-Scrapers,代码行数:8,代码来源:pipelines.py

示例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()
开发者ID:balancerockmedia,项目名称:multivalue-widget-python,代码行数:8,代码来源:multivalue_widget_python_tests.py

示例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)
开发者ID:mknudtsen,项目名称:event-data,代码行数:8,代码来源:pipelines.py

示例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()
开发者ID:luizbag,项目名称:pyref,代码行数:9,代码来源:pyref.py

示例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()
开发者ID:hathcox,项目名称:ShodanDorks,代码行数:10,代码来源:__main__.py

示例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())
开发者ID:SYNchroACK,项目名称:RootTheBox,代码行数:11,代码来源:rootthebox.py

示例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)
开发者ID:daoanhnhat1995,项目名称:CS-4392-Keep-It-Fresh,代码行数:12,代码来源:pipelines.py

示例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!")
开发者ID:skalawag,项目名称:ltc_stats,代码行数:13,代码来源:ticker_store.py


注:本文中的models.create_tables函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。