Came asyncpg — client library for PostgreSQL Python/asyncio

the EuroPython conference 2016 Yury Selivanov (the author of async/await syntax and the author of uvloop) has introduced a new high-performance library for asynchronous access to PostgreSQL — asyncpg. Tests show on average two times greater speed than psycopg2 (and its asynchronous variant aiopg).


The reason for high rates is that asyncpg implements binary Protocol PostgreSQL native, without the use of abstractions, like the DB-API. In addition, it is possible to obtain easy-to-use implementation:
the



the

Installation


asyncpg available on PyPI. Use pip to install:

the
$ pip install asyncpg


the

usage Example


the
import asyncio
import asyncpg

async def run():
conn = await asyncpg.connect(user='user', password='password',
database='database', host='127.0.0.1')
values = await conn.fetch("'SELECT * FROM mytable"')
await conn.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(run())


PS Some of the terms such as the "prepared statement", I left without translation, and also took the liberty to use text anglicisms, as I believe meticulous translation of technical texts can distort the original meaning or hamper understanding. Please forgive me for this.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Performance comparison of hierarchical models, Django and PostgreSQL

Transport Tycoon Deluxe / Emscripten part 2

google life search