Skip to main content

An asyncio PosgtreSQL driver

Project description

https://travis-ci.org/MagicStack/asyncpg.svg?branch=master https://ci.appveyor.com/api/projects/status/9rwppnxphgc8bqoj/branch/master?svg=true https://img.shields.io/pypi/v/asyncpg.svg

asyncpg is a database interface library designed specifically for PostgreSQL and Python/asyncio. asyncpg is an efficient, clean implementation of PostgreSQL server binary protocol for use with Python’s asyncio framework. You can read more about asyncpg in an introductory blog post.

asyncpg requires Python 3.5 or later and is supported for PostgreSQL versions 9.1 to 9.6.

Documentation

The project documentation can be found here.

Performance

In our testing asyncpg is, on average, 3x faster than psycopg2 (and its asyncio variant – aiopg).

performance.png

The above results are a geometric mean of benchmarks obtained with PostgreSQL client driver benchmarking toolbench.

Features

asyncpg implements PostgreSQL server protocol natively and exposes its features directly, as opposed to hiding them behind a generic facade like DB-API.

This enables asyncpg to have easy-to-use support for:

  • prepared statements

  • scrollable cursors

  • partial iteration on query results

  • automatic encoding and decoding of composite types, arrays, and any combination of those

  • straightforward support for custom data types

Installation

asyncpg is available on PyPI and has no dependencies. Use pip to install:

$ pip install asyncpg

Basic Usage

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())

License

asyncpg is developed and distributed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

asyncpg-0.9.0.dev1-cp36-cp36m-win_amd64.whl (584.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

asyncpg-0.9.0.dev1-cp36-cp36m-win32.whl (549.2 kB view details)

Uploaded CPython 3.6m Windows x86

asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6m

asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_i686.whl (1.4 MB view details)

Uploaded CPython 3.6m

asyncpg-0.9.0.dev1-cp35-cp35m-win_amd64.whl (577.6 kB view details)

Uploaded CPython 3.5m Windows x86-64

asyncpg-0.9.0.dev1-cp35-cp35m-win32.whl (543.3 kB view details)

Uploaded CPython 3.5m Windows x86

asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.5m

asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_i686.whl (1.4 MB view details)

Uploaded CPython 3.5m

asyncpg-0.9.0.dev1-cp35-cp35m-macosx_10_11_x86_64.whl (837.4 kB view details)

Uploaded CPython 3.5m macOS 10.11+ x86-64

File details

Details for the file asyncpg-0.9.0.dev1-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 243cd670a61b8890fc2ad11e5397d5f648130fa34c8e4510bd93b7b3be0eabec
MD5 57f9b7874ae9adc01bddde83dcfdd6b6
BLAKE2b-256 137ff53b5aa1d6b2003ae2ad12560ddb555ad43461c5c97c055fd2197b8f6c50

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 a97ed733195de137068cb2b311505eede608d852b0f115827f0dc38e6b3c5b82
MD5 c82e79a2ae66876bcdfc3d4671d3c92f
BLAKE2b-256 c969644d341687c2fad055c2406afca727594c1212bf669428ec6014090ab46d

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 06690a6047f63722ffdff27b4258ec9a0d65a0535036ee212470af1a8eb1b0c3
MD5 f9eb48adfeba2a41600252b7294fefc5
BLAKE2b-256 9d9f08895265376768f829f150520ff79769568665b9940c66518be771cb7b6a

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8577564476a713239ac67254fad03ad0417e16c9a038423041771122b0888d93
MD5 19abd6cb51e62f679f0f73a2aaf3f15b
BLAKE2b-256 bec719d84b449eab0d1f8bd84404eb833f409c26ac8577c48fdd6a27ccca016d

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 571128c14cfca00083a57873741bbd07a98952239f7185995088451c9bf85a9e
MD5 79c74c69c12ada15e97a5cabd87f8101
BLAKE2b-256 aaeaf11c9e6983fd056b05b51b467119d3e6c5eab6ac6d7dccfb4ddb1e31fea7

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 0e71dbefbdbdd040d6ab39a13151dffeeb8ab43df2f6c2c88d7d6f3bc7746d6b
MD5 8407198f02877cb97bba352e47e91f5e
BLAKE2b-256 cc5c8e86b1277a997f234be873863942eedeb31e99a01ff56546df03995179c7

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 931574edc116c41263d3026c451f589ab6aa22758e9510b372752a3e550cdd5c
MD5 aba78f1edfe4465642d2ad8960d6ca89
BLAKE2b-256 00af65990af5abb0008aac23c6b1dca597c2a619f387e173413e0a7c89d3d35a

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d5a9152a5d852d9da1374cb2f3680545d0bdfb595650883b5f90b52794aed77c
MD5 6115a389b456aa9f4f811eb1c900d91a
BLAKE2b-256 1d0e61783fe27aedb3cd7a620022799af752901c3c6c3fd0e623eff6517bda11

See more details on using hashes here.

File details

Details for the file asyncpg-0.9.0.dev1-cp35-cp35m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.9.0.dev1-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 a423bdac9d4b1d6c06e9599ed3eaf0f7ae9dfdbee07915a66207439e2ab55268
MD5 bd5d6d773ef1c9f060c2e92a3cb8023a
BLAKE2b-256 daa380297fef787a5c81b5f5c419e5f33a66e094d2df8d14069f7cc6465c52e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page