用于通过本机接口从asyncio访问clickhouse数据库的库
aioch的Python项目详细描述
#aioch
**aioch**是一个通过本机接口从异步访问clickhouse数据库的库。
它包装了异步使用的[clickhouse驱动程序](https://github.com/mymarilyn/clickhouse-driver)的功能。
[![覆盖状态](https://coveralls.io/repos/github/mymarilyn/aioch/badge.svg?branch=master)(https://coveralls.io/github/mymarilyn/aioch?分支=主)
[![构建状态](https://travis-ci.org/mymarilyn/aioch.svg?(https://travis ci.org/mymarillyn/aioch/mymarillyn/aioch)
可以使用‘pip `:
` `` bash
pip install aioch
` ` ` ` ` ` `
` ` ` ` ` ` ` `
` ` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` `
python setup.py安装##用法
``python
from datetime import datetime
import asyncio
from aioch import client
async def exec_progress():
client=client('localhost')
progress=await client.execute with_progress('long and complex query')
timeout=20对于num_rows,正在进行的total_rows:
done=num_rows/total_rows if total_rows else total_rows
now=datetime.now()
如果处理50%的行需要20秒以上,则取消查询。
if(now-started_at).total_seconds()>;timeout and done<;0.5:
等待客户端。cancel()
break
否则:
rv=await progress.get_result()
打印(rv)
async def exec_no_progress():
client=client('localhost')
rv=await client.execute('long and complex query')
打印(rv
=asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([exec_progress(),exec_no_progress()])
````
>有关详细信息,请参阅**clickhouse driver**用法示例。
如果未提供默认执行器,则将使用
*`loop`-与异步兼容的事件循环
其他参数将传递给包装好的clickhouse驱动程序客户端。
**aioch**是一个通过本机接口从异步访问clickhouse数据库的库。
它包装了异步使用的[clickhouse驱动程序](https://github.com/mymarilyn/clickhouse-driver)的功能。
[![覆盖状态](https://coveralls.io/repos/github/mymarilyn/aioch/badge.svg?branch=master)(https://coveralls.io/github/mymarilyn/aioch?分支=主)
[![构建状态](https://travis-ci.org/mymarilyn/aioch.svg?(https://travis ci.org/mymarillyn/aioch/mymarillyn/aioch)
可以使用‘pip `:
` `` bash
pip install aioch
` ` ` ` ` ` `
` ` ` ` ` ` ` `
` ` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` `
python setup.py安装##用法
``python
from datetime import datetime
import asyncio
from aioch import client
async def exec_progress():
client=client('localhost')
progress=await client.execute with_progress('long and complex query')
timeout=20对于num_rows,正在进行的total_rows:
done=num_rows/total_rows if total_rows else total_rows
now=datetime.now()
如果处理50%的行需要20秒以上,则取消查询。
if(now-started_at).total_seconds()>;timeout and done<;0.5:
等待客户端。cancel()
break
否则:
rv=await progress.get_result()
打印(rv)
async def exec_no_progress():
client=client('localhost')
rv=await client.execute('long and complex query')
打印(rv
=asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([exec_progress(),exec_no_progress()])
````
>有关详细信息,请参阅**clickhouse driver**用法示例。
如果未提供默认执行器,则将使用
*`loop`-与异步兼容的事件循环
其他参数将传递给包装好的clickhouse驱动程序客户端。