|
1 | | -Development |
| 1 | +asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio |
| 2 | +======================================================================= |
| 3 | + |
| 4 | +**asyncpg** is a database interface library designed specifically for |
| 5 | +PostgreSQL and Python/asyncio. asyncpg is an efficient, clean implementation |
| 6 | +of PostgreSQL server binary protocol for use with Python's ``asyncio`` |
| 7 | +framework. |
| 8 | + |
| 9 | + |
| 10 | +Performance |
2 | 11 | ----------- |
3 | 12 |
|
4 | | -1. Activate a Python 3.5 venv with the latest Cython installed; |
| 13 | +In our testing asyncpg is, on average, **2x** faster than psycopg2 |
| 14 | +(and its asyncio variant -- aiopg). |
| 15 | + |
| 16 | + |
| 17 | +Features |
| 18 | +-------- |
| 19 | + |
| 20 | +asyncpg implements PostgreSQL server protocol natively and exposes its |
| 21 | +features directly, as opposed to hiding them behind a generic facade |
| 22 | +like DB-API. |
| 23 | + |
| 24 | +This enables asyncpg to have easy-to-use support for: |
| 25 | + |
| 26 | + * **prepared statements** |
| 27 | + * **scrollable cursors** |
| 28 | + * **partial iteration** on query results |
| 29 | + * automatic encoding and decoding of composite types, arrays, |
| 30 | + and any combination of those |
| 31 | + * straightforward support for custom data types |
| 32 | + |
| 33 | + |
| 34 | +Basic Usage |
| 35 | +----------- |
| 36 | + |
| 37 | +.. code-block:: python |
| 38 | +
|
| 39 | + import asyncio |
| 40 | + import asyncpg |
| 41 | +
|
| 42 | + async def run(): |
| 43 | + conn = await asyncpg.connect(user='user', password='password', |
| 44 | + database='database', host='127.0.0.1') |
| 45 | + values = await conn.fetch('''SELECT * FROM mytable''') |
| 46 | + await conn.close() |
| 47 | +
|
| 48 | + loop = asyncio.get_event_loop() |
| 49 | + loop.run_until_complete(run()) |
| 50 | +
|
| 51 | +
|
| 52 | +License |
| 53 | +------- |
5 | 54 |
|
6 | | -2. run ``$ make`` to build asyncpg. |
| 55 | +asyncpg is developed and distributed under the Apache 2.0 license. |
0 commit comments