本文整理汇总了Python中peewee.SqliteDatabase.create_table方法的典型用法代码示例。如果您正苦于以下问题:Python SqliteDatabase.create_table方法的具体用法?Python SqliteDatabase.create_table怎么用?Python SqliteDatabase.create_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类peewee.SqliteDatabase
的用法示例。
在下文中一共展示了SqliteDatabase.create_table方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from peewee import SqliteDatabase [as 别名]
# 或者: from peewee.SqliteDatabase import create_table [as 别名]
def init(dbname="blender-models.db"):
db = SqliteDatabase(path.join(MORSEWEB_ROOT, dbname))
db.connect()
if not BlenderModel.table_exists():
db.create_table(BlenderModel)
for pathname in RESOURCES:
populate(pathname)
示例2: init
# 需要导入模块: from peewee import SqliteDatabase [as 别名]
# 或者: from peewee.SqliteDatabase import create_table [as 别名]
def init():
path = os.path.expanduser('~/.config/aesop/database.db')
global database
database = SqliteDatabase(path)
database_proxy.initialize(database)
database.connect()
for model in BaseModel.__subclasses__():
try:
database.create_table(model)
except Exception:
pass
else:
if model == Config:
Config.create_default()
示例3: empty
# 需要导入模块: from peewee import SqliteDatabase [as 别名]
# 或者: from peewee.SqliteDatabase import create_table [as 别名]
def empty(self, *args, **options):
"""
Creates an empty content database for the Khan channel. This ensures
that an empty content database exists in the default distribution and
for tests.
Especially useful for creating an *EMPTY TEMPLATE*
retrievecontentpack empty en --template
"""
lang = args[1]
if not options.get('template', False):
content_db_path = topic_settings.CONTENT_DATABASE_PATH.format(
channel=topic_settings.CHANNEL,
language=lang,
)
else:
content_db_path = topic_settings.CONTENT_DATABASE_TEMPLATE_PATH.format(
channel=topic_settings.CHANNEL,
language=lang,
)
if os.path.exists(content_db_path):
if options.get("force", False):
os.unlink(content_db_path)
else:
raise CommandError(
"Content database already exists: {}".format(
content_db_path
)
)
db = SqliteDatabase(
content_db_path
)
db.connect()
db.create_table(Item, safe=True)
db.create_table(AssessmentItem, safe=True)
db.close()
self.complete(
_("Saved empty content database in {}.").format(
content_db_path
)
)
示例4: create_database
# 需要导入模块: from peewee import SqliteDatabase [as 别名]
# 或者: from peewee.SqliteDatabase import create_table [as 别名]
def create_database():
with open('data.db', 'w+') as f:
f.write('')
db = SqliteDatabase('data.db')
db.connect()
db.create_table(Client)