一、项目主页介绍
二、快速了解
Peewee 提供了面向对象式的数据库操作功能,其设计理念跟Django的Model很类似,只是Django的Model与Django耦合比较紧密,想单独使用其Model很难。peewee就提供了一个很好的选择,可以应用于类似于flask框架的数据库处理当中。简单的介绍如下:
①设计表格
from peewee import *
db = SqliteDatabase('people.db')
class Person(Model):
name = CharField()
birthday = DateField()
class Meta:
database = db # This model uses the "people.db" database.
②创建表格
grandma = Person.create(name='Grandma', birthday=date(1935, 3, 1))
③查询数据
grandma = Person.select().where(Person.name == 'Grandma L.').get()
④排序
for pet in Pet.select().where(Pet.owner == uncle_bob).order_by(Pet.name):
print(pet.name)
# prints:
# Fido
# Kitty
具体使用方法,请访问项目文档:http://docs.peewee-orm.com/en/latest/index.html
大家有什么其他好用的数据库框架,也可以下面留言;
本文暂时没有评论,来添加一个吧(●'◡'●)