RQlite的基于Ayncio的Python客户端。
AIOrqlite的Python项目详细描述
这个包包含一个异步的纯python rqlite客户端库。(基于正式的Pyrqlite库)
Requirements
- python–以下之一:
- cpython>;=3.6推荐(>;=3.4可能有用)
- rqlite服务器
Example
以下代码创建连接并执行一些语句:
importaiorqlite@aiorqlite.arunasyncdefmain():# Connect to the databaseasyncwithaiorqlite.connect(':memory:')asdb:asyncwithdb.cursor()ascursor:awaitcursor.execute('CREATE TABLE foo (id integer not null primary key, name text)')awaitcursor.executemany('INSERT INTO foo(name) VALUES(?)',seq_of_parameters=(('a',),('b',)))asyncwithdb.cursor()ascursor:# Read a single record with qmark parameter stylesql="SELECT `id`, `name` FROM `foo` WHERE `name`=?"awaitcursor.execute(sql,('a',))result=awaitcursor.fetchone()print(result)# Read a single record with named parameter stylesql="SELECT `id`, `name` FROM `foo` WHERE `name`=:name"awaitcursor.execute(sql,{'name':'b'})result=awaitcursor.fetchone()print(result)main()
此示例将打印:
{'id':1,'name':'a'}{'id':2,'name':'b'}
Paramstyle
仅支持qmark和named paramstyles(如pep 249中所定义)。
Limitations
不支持事务。
License
Pyrqlite(以及随后的Aiorqlite)是根据麻省理工学院的许可证发布的。有关详细信息,请参见许可证。