本文整理汇总了Python中model.db.create_all方法的典型用法代码示例。如果您正苦于以下问题:Python db.create_all方法的具体用法?Python db.create_all怎么用?Python db.create_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.db
的用法示例。
在下文中一共展示了db.create_all方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
"""To do before every test"""
self.client = app.test_client()
app.config['SECRET_KEY'] = '123'
app.config['TESTING'] = True
# connect to test database
connect_to_db(app, "postgresql:///testdb")
"""Creates tables and adds example data to testdb"""
db.create_all()
example_data()
with self.client as c:
with c.session_transaction() as sess:
sess['user'] = 1
示例2: __init__
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def __init__(self):
# create database
try:
ApplyMsg.query.all()
except:
db.create_all()
# user apply for beans
示例3: __init__
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def __init__(self):
logger.info("Notification Manager init...")
try:
Notification.query.all()
except:
db.create_all()
try:
NotificationGroups.query.all()
except:
db.create_all()
try:
UserNotificationPair.query.all()
except:
db.create_all()
logger.info("Notification Manager init done!")
示例4: __init__
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def __init__(self):
try:
VNode.query.all()
History.query.all()
except:
db.create_all(bind='__all__')
示例5: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
"""Stuff to do before every test."""
# Get the Flask test client
self.client = app.test_client()
# Create secret key to access session
app.secret_key = "ABC"
# Connect to fake database
connect_to_db(app, 'postgresql:///testdb')
db.create_all()
app.config['TESTING'] = True
example_data()
示例6: create_sql
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def create_sql(db):
db.create_all()
示例7: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
"""Before tests."""
self.client = app.test_client()
app.config['TESTING'] = True
# Connect to test database
connect_to_db(app, "postgresql:///testdb")
# Create tables and add sample data
db.create_all()
example_data()
示例8: clean_db
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def clean_db():
# In case tables haven't been created, create them
db.session.commit()
db.drop_all()
db.create_all()
示例9: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
self.client = app.test_client()
app.config['TESTING'] = True
#Connect to test db
connect_to_db(app, 'postgresql:///testdb')
#Create tables & add sample data
db.create_all()
example_data()
示例10: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
""" Stuff to do before every test """
app.config['TESTING'] = True
app.config['SECRET_KEY'] = 'key123'
self.client = app.test_client()
# Connect to test database (uncomment when testing database)
connect_to_db(app, "postgresql:///testdb")
# Create tables and add sample data (uncomment when testing database)
db.create_all()
example_data()
示例11: setUp
# 需要导入模块: from model import db [as 别名]
# 或者: from model.db import create_all [as 别名]
def setUp(self):
self.client = app.test_client()
app.config['TESTING'] = True
# Connect to test database
connect_to_db(app, "postgresql:///cals_test")
print "Built test db"
# Create tables and seed sample data
db.create_all()
test_data()