asyncpg
Another library, asyncpg, doesn't implement the Python DB-API. Instead, it provides an asynchronous API that is supposed to be used with asyncio, a Python library used to write concurrent code. It's outside the scope of this book to cover asynchronous programming, so we will only provide and explain a couple of simplified examples.
To install the library, use pip, just as in the previous sections. To install asyncpg on Windows, execute the python -m pip install asyncpg command. On Linux, the command will be pip3 install asyncpg.
As mentioned before, asynchronous execution implies firing a task and, while it is executing, doing something else. The asyncio.connect() function that is used to connect to the database is asynchronous. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access