当前位置: 首页>>代码示例>>Python>>正文


Python db.create_all函数代码示例

本文整理汇总了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()
开发者ID:jarogers095,项目名称:flasktaskr,代码行数:7,代码来源:test.py

示例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()
开发者ID:821869798,项目名称:LibraryManager,代码行数:8,代码来源:manage.py

示例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')
开发者ID:smifun,项目名称:python-learning,代码行数:8,代码来源:test_users.py

示例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)
开发者ID:powerlanguage,项目名称:mog,代码行数:11,代码来源:tests.py

示例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()
开发者ID:Pampipampupampa,项目名称:RealPython_NoDeploy,代码行数:11,代码来源:test_users.py

示例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()
开发者ID:sanajaved7,项目名称:fridgr,代码行数:41,代码来源:test_database.py

示例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()

开发者ID:wove,项目名称:flasktaskr,代码行数:13,代码来源:db_create.py

示例8: setUp

 def setUp(self):
     db.create_all()
开发者ID:noamoss,项目名称:notifier,代码行数:2,代码来源:tests.py

示例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
开发者ID:franksalas,项目名称:PythonTaskManager,代码行数:19,代码来源:db_create.py


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