python peewee的笔记

个人笔记。。

```

from peewee import *

db=SqliteDatabase('people.db')

class Person(Model):

    name=CharField()

    birthday=DateField()

    is_relative=BooleaField()

    class Meta:

        database=db

```

1.先导入peewee的包

2.建立一个NoSQL或者SQL的对象

3.建立一个model类 其中model类里包含Meta类

4. 进行数据库的连接,如: db.connect()

5.进行数据库的操作,如:db.creata_tables() 建议数据库 或者用已经建立的model类进行操作,如:Person.create(name='???',birthday='???',is_relative='???')

操作方式:Person.create(),Person.delete_instance(),Person.select().where(\w+='\w')  and  group_by(),having(),limt() and offset() , save(),insert(),update()。。。。增删查改

join() 连接 

 ```

for x in Person.select().where() :

    print x

```


疑问:class Meta 代表什么?大概代表对sql语句查询的限制条件..

明天继续学习..peewee文档链接 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容