通过AsyncPg使用Postgres SQL的模块
aioworkers-pg的Python项目详细描述
用于所有工作人员的AsyncPG插件。
用法
将此添加到aioworkers config.yaml:
db:cls:aioworkers_pg.base.Connectordsn:postgresql:///test
您可以通过上下文在任何地方访问Postgres:
awaitcontext.db.execute('CREATE TABLE users(id serial PRIMARY KEY, name text)')awaitcontext.db.execute(users.insert().values(name='Bob'))
储存
storage:cls:aioworkers_pg.storage.RoStoragedsn:postgresql:///testtable:mytable# optional instead custom sqlkey:idget:SELECT * FROM mytable WHERE id = :id# optional custom sqlformat:dict# or row
开发
安装开发要求:
pipenv install --dev --skip-lock
运行测试:
pytest