FoundationDB的异步驱动程序
asyncio-foundationdb的Python项目详细描述
< PosiDB驱动程序AssiCIO用Cypthon 3.5 ++/P>测试
In[1]:importfoundIn[2]:importasyncioIn[3]:found.api_version(600)In[4]:loop=asyncio.get_event_loop()In[5]:db=loop.run_until_complete(found.open())In[6]:tr=db._create_transaction()In[7]:loop.run_until_complete(tr.get(b'hello'))In[8]:tr.set(b'hello',b'world')In[9]:loop.run_until_complete(tr.get(b'hello'))Out[9]:b'world'
还支持@transactional。
开始
pip install asyncio-foundationdb
文档
你必须阅读official python api documentation, 太棒了。
一般来说,异步绑定是相同的,只是 async和await必须在这里和那里添加。
以下是与同步绑定的区别:
- 没有像这样的速记语法:foo[b'bar']
- 你可以做value is None,而不是value == None
- Transaction.get_range返回(key, value)对的列表
如果遗漏了什么,那就是一个bug,please fill an issue。