5 ms·
asyncpg was developed by @redcrowbar and me. Ask us anything ;)
by 1st1 10y ago
asyncpg was developed by @redcrowbar and me. Ask us anything ;)
- Veratyr 10y agoDoes this automatically escape/convert things like datetimes in a query or does that need to be done separately? The docs are a little sparse on details. Looks fantastic anyway!
- RedCrowbar 10y agoYes, query arguments are converted automatically. Results are converted into Python types as expected (including arrays and composite types).
- rdtsc 10y agoGreat work, thanks for sharing. Very impressive speed. I didn't know about uvloop, that's a cool project: http://magic.io/blog/uvloop-blazing-fast-python-networking/ http://magic.io/blog/uvloop-blazing-fast-python-networking/
- 1st1 10y agoYep, it's also much more stable now, 3 months after that article was posted. I plan to make a new blog post about it soon.
- random42 10y agoMay be I am reading the benchmarks wrong, but does it mean I can get a 2x speedup in my end to end query execution from moving from aiopg to asynpg alone without any server side changes or query optimizations?
- RedCrowbar 10y agoWe intentionally benchmarked simple queries to measure the overhead of the driver implementation. So, the 2x speedup really means 50% reduction in overhead.
- welder 10y agoHow can I use it with SQLAlchemy instead of psycopg2?
- RedCrowbar 10y agoSQLAlchemy ORM is not async, so there is no way currently to use any async dialect for it. However, it is possible to write an SQLAlchemy Core adapter for asyncpg.
- infinite8s 10y agoIt might even be easier than writing an adapter if you just use SQLAlchemy Core's DSL as the generative mechanism for a SQL statement that is sent to asyncpg.
- RedCrowbar 10y agoThere appears to be an adapter for Core already: https://github.com/CanopyTax/asyncpgsa https://github.com/CanopyTax/asyncpgsa
- nhumrich 10y agoAuthor of asyncpgsa here, I am in the process of writing that, let me know if you have questions.
- andrioni 10y agoDo you have any numbers on queries that return millions of rows? If it's still fast, asyncpg could be nice for some ETL-type workloads.
- 1st1 10y agoWe haven't benchmarked this specific use case. However, cursors in asyncpg do data prefetching (the exact number of prefetched rows is configurable), so I expect that asynchronous iteration should be pretty fast (and still faster than psycopg2).
- Keats 10y agoI'd love to read the docs for the protocol itself, is it planned? Do you have a link explaining it otherwise? Great work!
- RedCrowbar 10y agoThe protocol is documented in the official PostgreSQL documentation: https://www.postgresql.org/docs/current/static/protocol.html https://www.postgresql.org/docs/current/static/protocol.html
- Keats 10y agoI meant a doc explaining roughly the components at https://github.com/MagicStack/asyncpg/tree/master/asyncpg/protocol https://github.com/MagicStack/asyncpg/tree/master/asyncpg/pr... and how they interact with each other at a high level as it doesn't seem to have comments. Thanks for the link though, I'll have a look
- 1st1 10y agoYeah, documenting internals sounds like a good idea. At least to make it easier for people to contribute and further improve asyncpg. We'll try to find some time to do that.
- glogla 10y agoBit offtopic, but what are the plots made with?
- RedCrowbar 10y agoHandmade with d3.js