• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.create_tables函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.create_tables函数的典型用法代码示例。如果您正苦于以下问题:Python create_tables函数的具体用法?Python create_tables怎么用?Python create_tables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_tables函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: get_players

def get_players():
    """Gets player listings from db"""
    engine = models.db_connect()
    models.create_tables(engine)
    Session = sessionmaker(bind=engine)
    session = Session()
    players = {}

    for player in session.query(models.NFL_Player_2015):
        players[str(player.name)] = 0

    session.close()

    return players
开发者ID:AncillaryStats,项目名称:AS-Ext-Apis,代码行数:14,代码来源:trending.py


示例17: __init__

    def __init__(self, db_url, **settings):
        if db_url is not None:
            engine = create_engine(db_url,
                                   connect_args={'sslmode': 'require'})
            create_tables(engine)

            self.db = scoped_session(sessionmaker(bind=engine))

        handlers = [
            (r"/", MainHandler),
        ] + repo_crud.handlers + github_handlers.handlers

        settings['template_path'] = os.path.join(os.path.dirname(__file__),
                                                 "templates")
        settings['static_path'] = os.path.join(os.path.dirname(__file__),
                                               "static")
        super().__init__(handlers, **settings)
开发者ID:stillinbeta,项目名称:heroku-starter-project,代码行数:17,代码来源:main.py


示例18: test_add_playground

    def test_add_playground(self):
        models.delete_tables()
        models.create_tables()

        response = self.client.post(url_for('insert_playground'), data={
            'name': 'NEW PLAYGROUND'
        })

        self.assertEqual(response.status_code, 302)

        redirect_url = app_config.S3_BASE_URL
        self.assertEqual(response.headers['Location'].split('?')[0], redirect_url + '/search.html')

        with open('data/changes.json') as f:
            inserts = json.load(f)

        self.assertEqual(len(inserts), 1)
        self.assertEqual(inserts[0]['action'], 'insert')
        self.assertEqual(inserts[0]['playground']['name'], 'NEW PLAYGROUND')
开发者ID:imclab,项目名称:playgrounds2,代码行数:19,代码来源:test_public_app.py


示例19: __init__

    def __init__(self):
        engine = db_connect()
        create_tables(engine)
        self.Session = sessionmaker(bind=engine)

        session = self.Session()

        # make sure the root of the product type tree exists
        ptt = session.query(ProductTypeTree).filter_by(lft=0).first()
        if ptt is None:
            ptt = ProductTypeTree(name='Root', lft=0, rgt=1)
            try:
                session.add(ptt)
                session.commit()
            except:
                session.rollback()
                raise
            finally:
                session.close()
开发者ID:rhololkeolke,项目名称:EECS_341_Project,代码行数:19,代码来源:pipelines.py


示例20: __init__

    def __init__(self, db_url, **settings):
        if db_url is not None:
            engine = create_engine(db_url,
                                   echo=True,
                                   connect_args={'sslmode': 'require'})
            create_tables(engine)

            self.db = scoped_session(sessionmaker(bind=engine))

        handlers = [
            (r"/", MainHandler),
            URLSpec(r"/repos", RepoList, name='repo_list'),
            URLSpec(r"/repos/add", RepoAdd, name='repo_add'),
            URLSpec(r"/repos/(\d+)", RepoEdit, name='repo_edit'),
        ]

        settings['template_path'] = os.path.join(os.path.dirname(__file__),
                                                 "templates")
        settings['static_path'] = os.path.join(os.path.dirname(__file__),
                                               "static")
        super().__init__(handlers, **settings)
开发者ID:idan,项目名称:heroku-starter-project,代码行数:21,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.db_connect函数代码示例发布时间:2022-05-27
下一篇:
Python modeller.model函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap