-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A database client should be based on asyncio #141
Comments
Agreed, this should have had its own enhancement request/issue before now. |
@elrik75 No, it shouldn't yet. |
Hello everyone! |
The |
To clarify, I see this issue as an enhancement request to either create a clean async wrapper around the library that feels more "async native" or even better, use a true async HTTP client. The urllib3 library doesn't use any async io so in that sense |
+1 , feel like this is a required feature for a modern python library |
Mind elaborating what you mean with brain-dead? It's very usable and used everywhere. What aspect of it is brain-dead and better than thread-blocking urllib3 (which means much more brain-dead to me)? |
Hi @elrik75 @araa47 @genzgd @vsbaldeev , |
Essentially brain-dead is the "all or nothing" implementation. No project can be converted to async ever without a complete rewrite of that project and all of the libraries it uses. And the libraries that use these libraries. |
That's correct. The point is more: what kind of DB client should CH support then? sync or async? What kind makes more sense? My point of view (because I work on backend servers) is that a sync IO lib is not very helpful. |
@alexted We in the process of defining the roadmap for To be clear, this is definitely work we want to do, but it may take a while to come to the top of the priority list given all of the work on other projects. As always, community contributions to help us get moving in the right direction are always appreciated. :) |
In case anyone is struggling with this, if the postgres connection port is open, you can connect to clickhouse with psycopg3: conn = await psycopg.AsyncConnection.connect(
dbname='default',
user='default',
password='...',
host='localhost',
port='9005',
cursor_factory=psycopg.AsyncClientCursor,
autocommit=True,
) You need All data types seem to be returned as strings, but it's better than nothing (and pydantic does a pretty good job of coercing data to an expected type) |
I've added an example of how to run If you do experiment with similar solutions, please report your results (good or bad) here. |
Since 0.7.16, ClickHouse-Connect provides a convenience |
This is very unfortunate. As I think I said to @tbragin, pretending to have any async client by just running the sync code in a thread pool is an own goal for ClickHouse. It'll often be slower than just using the sync client. You'd be better off either recommending clickhouse-connect/clickhouse_connect/driver/asyncclient.py Lines 79 to 88 in ee3af79
To actually solve this properly, you need to either:
|
@samuelcolvin, As you can see, the issue is not closed. We will support asyncio natively, however the implementation will take time. |
@samuelcolvin Putting aside the Arrow Flight question for the moment, I'm not sure what problem you are trying to "solve". Queries run using the wrapper yield the asyncio event loop when waiting for the HTTP I/O. So your main thread will spend its time in the CPU bound parts of the query (generally, transforming data). The fact that I can assure you that using |
Major DBs have their asyncio client nowdays:
It's logical for any I/O access for python to be async.
Note that there is an unmaintained async client for clickhouse: https://github.com/maximdanilchenko/aiochclient
Having an official async client for clickhouse with cython and full-featured will be great !
The text was updated successfully, but these errors were encountered: