本文整理汇总了Python中views.db.create_all函数的典型用法代码示例。如果您正苦于以下问题:Python create_all函数的具体用法?Python create_all怎么用?Python create_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_all函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + \
os.path.join(basedir, TEST_DB)
self.app = app.test_client()
db.create_all()
示例2: createall
def createall():
db.create_all()
f = open("static/默认数据.txt","r",encoding="utf-8")
for line in f.readlines():
if line:
db.session.execute(line)
f.close()
db.session.commit()
示例3: setUp
def setUp(self):
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(basedir, TEST_DIR)
self.app = app.test_client()
db.create_all()
self.michaelUser = ('Michael', '[email protected]', 'python', 'python')
示例4: setUp
def setUp(self):
"""Set up."""
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['DEBUG'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(basedir, TEST_DB)
self.app = app.test_client()
db.create_all()
self.assertEquals(app.debug, False)
示例5: setUp
def setUp(self):
"""
Executing prior to each tasks.
Create environnement where tests while be executing.
"""
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(basedir, TEST_DB)
self.app = app.test_client()
db.create_all()
示例6: setUp
def setUp(self):
db.create_all()
# Adding Users
user = User(name='user1', email="[email protected]")
user2 = User(name='user2', email="[email protected]")
user3 = User(name='user3', email="[email protected]")
db.session.add_all([user, user2, user3])
# Adding Families
family = Family(name='Family-name-1', members=[user, user2])
family2 = Family(name='Family-name-2', members=[user, user3])
db.session.add_all([family, family2, user3])
# Adding Fridges
fridge = Fridge()
fridge2 = Fridge()
db.session.add_all([fridge, fridge2])
family.fridge = fridge
family2.fridge = fridge2
# Adding Grocery Lists
grocery_list = GroceryList(name="listname1")
grocery_list2 = GroceryList(name="listname2")
grocery_list3 = GroceryList(name="listname3")
db.session.add_all([grocery_list, grocery_list2, grocery_list3])
family.grocery_lists.append(grocery_list)
family.grocery_lists.append(grocery_list2)
family2.grocery_lists.append(grocery_list3)
db.session.commit()
# Adding items
item1 = Item(name="item1", family_pk=family.pk)
item2 = Item(name="item2", family_pk=family.pk)
item3 = Item(name="item3", family_pk=family.pk)
item4 = Item(name="item4", family_pk=family2.pk)
item5 = Item(name="item5", family_pk=family2.pk)
db.session.add_all([item1, item2, item3, item4, item5])
# Adding items to fridge
fridge.items.append(item1)
fridge2.items.append(item2)
# Adding items to grocery lists
grocery_list.items.append(item3)
grocery_list3.items.append(item4)
grocery_list3.items.append(item5)
db.session.commit()
示例7: date
from views import db
from models import Task
from datetime import date
# Create the database and tables
db.create_all()
# Insert data
db.session.add(Task('Finish this tutorial', date(2015, 03, 06), 10, 1))
db.session.add(Task('Finish this course', date(2015, 04, 06), 10, 1))
# Commit the changes
db.session.commit()
示例9: date
from views import db
from models import Task
from datetime import date
# create the database and the db table
db.create_all() # initialize the database shcema
# insert data
db.session.add(Task("Finish this tutorial", date(2015, 3, 13), 10, 1))
db.session.add(Task("fishish realpython", date(2015, 3, 13), 10, 1))
# populate te table with data via the Task object form models.py to specify the schema
# commit the changes
db.session.commit()
# to apply the previous thanges we commit