本文整理匯總了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()