本文整理汇总了Python中models.db.drop_all函数的典型用法代码示例。如果您正苦于以下问题:Python drop_all函数的具体用法?Python drop_all怎么用?Python drop_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例2: run
def run(app=app):
"""
Creates the database in the application context
:return: no return
"""
with app.app_context():
db.drop_all()
示例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()
示例4: tearDown
def tearDown(self):
"""
Remove/delete the database and the relevant connections
!
:return: no return
"""
db.session.remove()
db.drop_all()
示例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"
示例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()
示例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.")
示例8: create_db
def create_db():
db.drop_all()
# db.configure_mappers()
db.create_all()
create_characters()
create_houses()
create_books()
db.session.commit()
示例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
示例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.")
示例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()
示例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()
示例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()
示例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()
示例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