与muffin框架的peewee集成
muffin-peewee的Python项目详细描述
muffin peewee–与muffin框架的peewee orm集成。
内容
Requirements
- python>;=3.5.3
Usage
在您的muffin应用程序配置中添加muffin_peewee到插件。
或者像这样手动安装:
db = muffin_peewee.Plugin(**{'options': 'here'}) app = muffin.Application('test') app.install(db)
Options
peeweeu连接–连接到数据库的字符串(sqlite:///db.sqlite)
< > PeeWeiLnCalnsixPARAMS< /CIT> >连接的附加参数({})
Peeweeu连接手册–不会自动管理数据库连接
peewee_migrations_enabled–启用迁移(true)
peewee_migrations_path–迁移文件夹的路径(迁移)
Queries
@app.ps.peewee.register class Test(peewee.Model): data = peewee.CharField() @app.register def view(request): return [t.data for t in Test.select()]
Manage connections
# Set configuration option `PEEWEE_CONNECTION_MANUAL` to True # Use context manager @app.register def view(request): with (yield from app.ps.peewee.manage()): # Work with db # ...
Migrations
创建迁移:
$ muffin example:app create [NAME] [--auto]
运行迁移:
$ muffin example:app migrate [NAME] [--fake]
回滚迁移:
$ muffin example:app rollback NAME
Load/Dump data to CSV
将表测试转储到csv文件:
$ muffin example:app csv_dump test
将csv文件中的数据加载到表test:
$ muffin example:app csv_load test
Bug tracker
如果您有任何建议、错误报告或 烦恼请向问题追踪者报告 在https://github.com/klen/muffin-peewee/issues
Contributors
- klen(基里尔·克莱诺夫)
License
根据MIT license授权。
如果你想对这个项目表示感谢,欢迎你寄来 明信片寄往:
Kirill Klenov pos. Severny 8-3 MO, Istra, 143500 Russia