本文整理匯總了Python中playhouse.sqlite_ext.SqliteExtDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Python sqlite_ext.SqliteExtDatabase方法的具體用法?Python sqlite_ext.SqliteExtDatabase怎麽用?Python sqlite_ext.SqliteExtDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類playhouse.sqlite_ext
的用法示例。
在下文中一共展示了sqlite_ext.SqliteExtDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: makedb
# 需要導入模塊: from playhouse import sqlite_ext [as 別名]
# 或者: from playhouse.sqlite_ext import SqliteExtDatabase [as 別名]
def makedb(dbfile):
db = SqliteExtDatabase(dbfile)
db.connect()
global BaseModel
class BaseModel(Model):
class Meta:
database = db
global UniqueString
class UniqueString(BaseModel):
raw = CharField(index=True)
count = IntegerField()
malware_count = IntegerField()
p_malware = FloatField(index=True)
global Entity
class Entity(BaseModel):
name = CharField(index=True)
label = FloatField()
global String
class String(BaseModel):
uniquestring = ForeignKeyField(UniqueString,index=True)
entity = ForeignKeyField(Entity,index=True)
source = CharField(index=True,null=True)
# create database
db.create_tables([Entity,String,UniqueString])
return db
示例2: __get_migrator
# 需要導入模塊: from playhouse import sqlite_ext [as 別名]
# 或者: from playhouse.sqlite_ext import SqliteExtDatabase [as 別名]
def __get_migrator(self):
if isinstance(self.db.engine, peewee.SqliteDatabase) or isinstance(self.db.engine, SqliteExtDatabase):
return SqliteMigrator(self.db.engine)
elif isinstance(self.db.engine, peewee.MySQLDatabase):
return MySQLMigrator(self.db.engine)
elif isinstance(self.db.engine, peewee.PostgresqlDatabase):
return PostgresqlMigrator(self.db.engine)
raise ImproperlyConfigured('Database engine doesn\'t support Migrations!')