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

Python db.drop_all函数代码示例

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

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



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

示例1: run

	def run(self):
		db.drop_all()
		db.create_all()
		db.session.add(Group('Diggers', 'Preschool'))
		db.session.add(Group('Discoverers', 'Year R-2'))
		db.session.add(Group('Explorers', 'Years 3-6'))
		db.session.commit()
开发者ID:nathan3000,项目名称:lesson_aims,代码行数:7,代码来源:manage.py


示例2: run

 def run(app=app):
     """
     Creates the database in the application context
     :return: no return
     """
     with app.app_context():
         db.drop_all()
开发者ID:jonnybazookatone,项目名称:biblib-service,代码行数:7,代码来源:manage.py


示例3: init_db

def init_db():
    db.drop_all()
    db.create_all()
    type_ids = {}
    rate_type_ids = {}
    for type_name in ["office", "meeting", "other"]:
        t = ListingType(type_name)
        db.session.add(t)
        db.session.commit()
        type_ids[type_name] = t
    for type_name in ["Hour", "Day", "Week", "Month", "3 Months", "6 Months", "Year"]:
        t = RateType(type_name)
        db.session.add(t)
        db.session.commit()
        rate_type_ids[type_name] = t
    db.session.add(Listing(address="1500 Union Ave #2500, Baltimore, MD",
                           lat="39.334497", lon="-76.64081",
                           name="Headquarters for Maryland Nonprofits", space_type=type_ids["office"], price=2500,
                           description="""Set in beautiful downtown Baltimore, this is the perfect space for you.

1800 sq ft., with spacious meeting rooms.

Large windows, free wifi, free parking, quiet neighbors.""", contact_phone="55555555555", rate_type=rate_type_ids['Month']))
    db.session.add(Listing(address="6695 Dobbin Rd, Columbia, MD",
                           lat="39.186198", lon="-76.824842",
                           name="Frisco Taphouse and Brewery", space_type=type_ids["meeting"], price=1700,
                           description="""Large open space in a quiet subdivision near Columbia.

High ceilings, lots of parking, good beer selection.""", rate_type=rate_type_ids['Day'], contact_phone="55555555555", expires_in_days=-1))
    db.session.add(Account("admin", "[email protected]", "Pass1234"))
    db.session.commit()
开发者ID:josephturnerjr,项目名称:spacefinder,代码行数:31,代码来源:db_functions.py


示例4: tearDown

    def tearDown(self):
        """
        Remove/delete the database and the relevant connections
!
        :return: no return
        """
        db.session.remove()
        db.drop_all()
开发者ID:jonnybazookatone,项目名称:gut-service,代码行数:8,代码来源:test_big_share_epic.py


示例5: testdb

def testdb():
  #if db.session.query("1").from_statement("SELECT 1").all():
  #  return 'It works.'
  #else:
  #  return 'Something is broken.'   
  db.drop_all()
  db.create_all()
  return "i got here"
开发者ID:jacobduron90,项目名称:flaskDrinks,代码行数:8,代码来源:app.py


示例6: tearDown

    def tearDown(self):
        db.session.remove()
        db.drop_all()

        os.close(self.db_fd)
        os.unlink(self.dbname)

        if self._ctx is not None:
            self._ctx.pop()
开发者ID:vimalkvn,项目名称:flask_security_example,代码行数:9,代码来源:flaskr_tests.py


示例7: tearDown

    def tearDown(self):
        info("Drop tables.")

        # Otherwise hangs at drop_all.
        # More info: http://stackoverflow.com/questions/24289808/
        db.session.commit()

        db.drop_all()
        info("Tables dropped.")
开发者ID:OAuthHub,项目名称:OAuthHub,代码行数:9,代码来源:user_functions_test.py


示例8: create_db

def create_db():
    db.drop_all()
    # db.configure_mappers()
    db.create_all()

    create_characters()
    create_houses()
    create_books()

    db.session.commit()
开发者ID:VectorCell,项目名称:gotdata,代码行数:10,代码来源:create_db.py


示例9: tearDown

 def tearDown(self):
     """
     Ensures that the database is emptied for next unit test
     """
     db.session.remove()
     db.drop_all()
     try:
         user = User.query.all()
     except Exception as e:
         assert e
开发者ID:stellasstar,项目名称:flask_app,代码行数:10,代码来源:tests.py


示例10: tearDown

    def tearDown(self):
        log.debug("Drop tables.")

        # Otherwise hangs at drop_all.
        # More info: http://stackoverflow.com/questions/24289808/
        db.session.commit()

        with app.app_context():
            db.drop_all()
        log.debug("Tables dropped.")
开发者ID:OAuthHub,项目名称:OAuthHub,代码行数:10,代码来源:models_test.py


示例11: setUpClass

    def setUpClass(cls):
        cls.app = app
        cls.app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://flask:[email protected]:5432/test_factory_boy'
        cls.app.config['SQLALCHEMY_ECHO'] = True
        db.app = cls.app

        db.init_app(cls.app)
        cls._ctx = cls.app.test_request_context()
        cls._ctx.push()
        db.drop_all()
        db.create_all()
开发者ID:citizen-stig,项目名称:factory_boy_253,代码行数:11,代码来源:tests.py


示例12: createdb

def createdb(testdata=False):
    """Initializes the database"""
    app = create_app()
    with app.app_context():
        db.drop_all()
        db.create_all()
        if testdata:
            user = User(username='john', password='oldman')
            db.session.add(user)

            db.session.commit()
开发者ID:andela-osule,项目名称:bucket-list-api,代码行数:11,代码来源:manager.py


示例13: db

def db(app, request):
    """Function-wide test database."""
    _db.create_engine(
        app.config['SQLALCHEMY_DATABASE_URI'], convert_unicode=True
    )
    _db.drop_all()
    _db.create_all()

    yield _db

    # Teardown
    _db.drop_all()
开发者ID:qqalexqq,项目名称:monkeys,代码行数:12,代码来源:conftest.py


示例14: init_all

def init_all():
    db.drop_all()
    db.create_all()
    init_descriptions(current_app.file_root)
    init_abilities()
    init_races()
    init_skills()
    init_classes()
    init_messages()
    init_characters()
    init_handlers()
    init_items()
    init_knowledge()
    init_alignments()
开发者ID:simonbw,项目名称:dndhelper,代码行数:14,代码来源:admin.py


示例15: reload_all

def reload_all():
    db.drop_all()
    db.create_all()

    with open(DATA_PATH) as f:
        data = loads(f.read())

    ability_map = {}
    for ability_data in data['abilities']:
        ability = Ability(ability_data['name'], ability_data['abbreviation'], ability_data['description'])
        ability_map[ability_data['id']] = ability
        db.session.add(ability)

    skill_map = {}
    for skill_data in data['skills']:
        ability = ability_map[skill_data['ability_id']]
        skill = Skill(skill_data['name'], ability, skill_data['description'])
        skill_map[skill_data['id']] = skill
        db.session.add(skill)

    alignment_map = {}
    for alignment_data in data['alignments']:
        alignment = Alignment(alignment_data['name'], alignment_data['description'])
        alignment_map[alignment_data['id']] = alignment
        db.session.add(alignment)

    race_map = {}
    for race_data in data['races']:
        race = Race(race_data['name'], race_data['description'])
        race_map[race_data['id']] = race
        db.session.add(race)

    class_map = {}
    for class_data in data['classes']:
        character_class = CharacterClass(class_data['name'], class_data['description'])
        class_map[class_data['id']] = character_class
        db.session.add(character_class)

    item_type_map = {}
    for item_type_data in data['item_types']:
        item_type_id = item_type_data['id']
        del item_type_data['id']
        item_type = ItemType(**item_type_data)
        item_type_map[item_type_id] = item_type
        db.session.add(item_type)

    db.session.commit()
    print data
    return data
开发者ID:simonbw,项目名称:dndhelper,代码行数:49,代码来源:admin.py


示例16: initdb

def initdb(newinstance=False):
    # Destroy and recreate tables
    ctx = app.test_request_context()
    ctx.push()
    if newinstance:
        db.drop_all()
    db.create_all()  
    categories = ['Projector', 'Camera', 'Laptop', 'Modem', 'Printer']
    for c in categories:
        if not DBCategory.query.filter(DBCategory.name == c).first():
            db.session.add(DBCategory(c)) 
    if not DBUser.query.filter(DBUser.username == 'admin').first():
        db.session.add(DBUser('admin', 'admin'))
        db.session.add(DBUser('jnhdny', 'steel'))
    DBUser.query.filter(DBUser.id > 2).delete()
    # Must commit to save
    db.session.commit()
    ctx.pop()
开发者ID:jnhdny,项目名称:nobreading,代码行数:18,代码来源:server.py


示例17: create_db

def create_db():
	db.drop_all()
	db.create_all()

	create_users()
	create_projects()

	db.session.commit()

	print()
	print('The database contains:')
	for user in User.query.all():
		print(repr(user))
		print('\tid:', user.id)
		print('\tname:', user.name)
	for project in Project.query.all():
		print(repr(project))
		print('\tid:', project.id)
		print('\tname:', project.name)
		print('\tauthor:', project.author)
		print('\tdescription:', project.description)
开发者ID:VectorCell,项目名称:bismith.net,代码行数:21,代码来源:create_db.py


示例18: User

from models import db, User, get_pair_list, get_user_list, \
    clear_all_users, clear_all_pairs, get_user_from_user_id

db.drop_all()
db.create_all()

clear_all_users()
clear_all_pairs()
dom = User("Dom", "[email protected]")
arthur = User("Arthur", "[email protected]")
isobel = User("Isobel", "[email protected]")
joe = User("Joe", "[email protected]")
dom.start()
arthur.start()
isobel.start()
joe.start()

user_list = get_user_list()
print "user list is: ", user_list
pair_list = get_pair_list()
print pair_list

# new match - success

dom_next_pair = dom.get_next_pair()
print "Dom's next pair is: ", dom_next_pair

match1 = dom.make_pair_match(dom_next_pair)
print "Made match 1 with id: ", match1.id

# new match - success
开发者ID:dom-mcloughlin,项目名称:matchmaker,代码行数:31,代码来源:wingman_matches_test.py


示例19: dbinit

def dbinit(): 
     db.drop_all()
     db.create_all()
开发者ID:stellasstar,项目名称:flask_app,代码行数:3,代码来源:app.py


示例20: tearDown

 def tearDown(self):
     db.session.close_all()
     db.drop_all()
开发者ID:Space-Cadets,项目名称:Oberon,代码行数:3,代码来源:test_signup.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db.init_app函数代码示例发布时间:2022-05-27
下一篇:
Python db.create_all函数代码示例发布时间: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