In [11]:
from model.db.tb1 import Tb1
query = Tb1.select().where(Tb1.id > 0)
print "select query:", query.sql()[0] % tuple(query.sql()[1])
print "query result:"
for item in query.dicts().execute():
print item
Tb1
是我们定义的一个Model
class Tb1(XYZ_DB.Model):
"""
"""
id = PrimaryKeyField()
name = CharField()
age = IntegerField()
create_time = DateTimeField()
class Meta(object):
"""表配置信息
"""
db_table = "tb1"
peewee对Model
类指定BaseModel
元类
class Model(with_metaclass(BaseModel)):
In [ ]: