Skip to main content
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.2 to 12.

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.

Release files for asyncpg 0.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncpg 0.20.0
File Size Uploaded
asyncpg-0.20.0.tar.gz 733.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for asyncpg 0.20.0
File
asyncpg-0.20.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
asyncpg-0.20.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
asyncpg-0.20.0-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
asyncpg-0.20.0-cp38-cp38-manylinux1_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-32 Details
asyncpg-0.20.0-cp38-cp38-macosx_10_13_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.13+ x86-64 Details
asyncpg-0.20.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
asyncpg-0.20.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
asyncpg-0.20.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.20.0-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.20.0-cp37-cp37m-macosx_10_13_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64 Details
asyncpg-0.20.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
asyncpg-0.20.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
asyncpg-0.20.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.20.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.20.0-cp36-cp36m-macosx_10_13_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ x86-64 Details
asyncpg-0.20.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
asyncpg-0.20.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
asyncpg-0.20.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.20.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.20.0-cp35-cp35m-macosx_10_13_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ x86-64 Details

Total release size: 35.5 MB

Release files / asyncpg-0.20.0.tar.gz

Download URL asyncpg-0.20.0.tar.gz
Size 733.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aa02dce5d5b801cff7dd2d99b767f5db312858f527ec1764777aad1fdefb5a7a
BLAKE2b-256 checksum
How to use checksums
8bec999cb396cec08e0f65340f3cdd38067fd76c5bf5140d1ae4f8ee29462816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp38-cp38-win_amd64.whl

Download URL asyncpg-0.20.0-cp38-cp38-win_amd64.whl
Size 1.1 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
ab8ea6a13ac536b171780024b099f5190c22fab93b6f787e2cf3b39c66d7a687
BLAKE2b-256 checksum
How to use checksums
30b7053c7ec94b6301dda26f123430deea53b7f6ed732d9a0f93815c80bc293e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp38-cp38-win32.whl

Download URL asyncpg-0.20.0-cp38-cp38-win32.whl
Size 1.0 MB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
ba17521b1a338051bd274dadf16f4fd04568a43d3a873d6d3daac6169f626bac
BLAKE2b-256 checksum
How to use checksums
d5caf58b94ea35071ed379f91555d8260f808f2a662fb7afa01dcc095f57441c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp38-cp38-manylinux1_x86_64.whl

Download URL asyncpg-0.20.0-cp38-cp38-manylinux1_x86_64.whl
Size 2.9 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
160925de20f3b3828654a0145992de966dd2b7e1d6bd3aa7204d7880bf848f70
BLAKE2b-256 checksum
How to use checksums
5e3108d8974ecf52dfe7879e3bf689de69628a9307698477a828c24cd5f243e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp38-cp38-manylinux1_i686.whl

Download URL asyncpg-0.20.0-cp38-cp38-manylinux1_i686.whl
Size 2.7 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
4ac7fa44803ba32ac421900016690df3147ad6b732360162701c2fbb9aaa043a
BLAKE2b-256 checksum
How to use checksums
71371b2dad11f4b8cfeb0c5312aaafaff397c01ac62fe17ba135edc1fa7ae346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp38-cp38-macosx_10_13_x86_64.whl

Download URL asyncpg-0.20.0-cp38-cp38-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.8 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
c6c2c502a454417c03a13a99667b922afe3389249080a5dbeae130594c97eb8f
BLAKE2b-256 checksum
How to use checksums
b73289b137cd6529e15e1951b5db30dc503584683ee15adcd0f8777e8e317565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp37-cp37m-win_amd64.whl

Download URL asyncpg-0.20.0-cp37-cp37m-win_amd64.whl
Size 1.1 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
b0ba2ae7b4a3d40611388e406bdda5c36bb580787c8fe70b28a33476347c699a
BLAKE2b-256 checksum
How to use checksums
bb959f15bef01675c42bf9291373e7cbf39754be84dd11dc3c2bffdc48300e03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp37-cp37m-win32.whl

Download URL asyncpg-0.20.0-cp37-cp37m-win32.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
265ba356e216c1a96f490b35b138321d2e6dcf40302e2cd0df3b474a42644ae4
BLAKE2b-256 checksum
How to use checksums
7d05f9e7b54792853b6b58fd1b60afff87bd4c2f5caf972f6a005ac8dbb0e039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL asyncpg-0.20.0-cp37-cp37m-manylinux1_x86_64.whl
Size 2.7 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
e6efb9752dc86a5321eaf565969c15d32cfb702c6f25c2356eea629264d99d3d
BLAKE2b-256 checksum
How to use checksums
180fa3c09242b31e43039c18c742bf3ad1e1fd6ffcea90d5eaa2a354b91fcac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp37-cp37m-manylinux1_i686.whl

Download URL asyncpg-0.20.0-cp37-cp37m-manylinux1_i686.whl
Size 2.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
14b73360da5b4febe3cb8d2f18148196843a4d4719f8db8412e2b858527473d7
BLAKE2b-256 checksum
How to use checksums
85184a63ebb5a014bbaa76f5e9fc86a9c5c30c3087066f3333f40ec653684d01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp37-cp37m-macosx_10_13_x86_64.whl

Download URL asyncpg-0.20.0-cp37-cp37m-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
64aa8330eb585b3804b298d0b5b1bc8d72b9345cce4f2e956b0ab85b1463b9f7
BLAKE2b-256 checksum
How to use checksums
195669643552a8535e98ee2a46103a8d47da7c822b44409befcaef3a8de0e3a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp36-cp36m-win_amd64.whl

Download URL asyncpg-0.20.0-cp36-cp36m-win_amd64.whl
Size 1.1 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
6a2a96d17e129ae7501c3fc323dc8d47d292113aa6e65c7c613e4e8374fb096e
BLAKE2b-256 checksum
How to use checksums
cfdac18fe13302f122ed4f9b2f052a561b7b35de28f80160e30dff758cf24df2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp36-cp36m-win32.whl

Download URL asyncpg-0.20.0-cp36-cp36m-win32.whl
Size 1.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
b32a03b8b18f96ea00711d495cf824bcf9d88e5268e89b26a7ec6cbf2a20f1dc
BLAKE2b-256 checksum
How to use checksums
0a03db40634f9512eb8319d9efcbe139229ba5acf7f87cd1b694663bdef87d5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL asyncpg-0.20.0-cp36-cp36m-manylinux1_x86_64.whl
Size 2.8 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
90d10514e2814c981b104b97d93decc154ffe63e4e3f6e9bb80df1bdac433fba
BLAKE2b-256 checksum
How to use checksums
edeb636b114de4f066ebb42cba9d8f5c81240fb0324f122cc10e7a91e631b446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp36-cp36m-manylinux1_i686.whl

Download URL asyncpg-0.20.0-cp36-cp36m-manylinux1_i686.whl
Size 2.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
0e4e5ed6134434fbc932dc069f07c326e3e4c128472f1145d25a7e68a60352bc
BLAKE2b-256 checksum
How to use checksums
0a119b0d10b7bf1e5981eb49991de3485dbf9e38fa7fc4a9e8a60a141fba8be6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp36-cp36m-macosx_10_13_x86_64.whl

Download URL asyncpg-0.20.0-cp36-cp36m-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
e70b41e7ec05d77042f12a67cdc3cc76a0c21718d1e82ee35e0c58dc9ddf387d
BLAKE2b-256 checksum
How to use checksums
fb302047b827359bd6695d5188f62ef7b387498240879c7c72e0b5906aa8171c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp35-cp35m-win_amd64.whl

Download URL asyncpg-0.20.0-cp35-cp35m-win_amd64.whl
Size 1.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
3d25a38326dc5184d014acaa4ab799cdfd4704eefc6d5ab0f9e3be395ea86e7d
BLAKE2b-256 checksum
How to use checksums
2e01faf33f26feb3deae2aeaa6d088b0252d2ada1544807a2a0335aa06618a67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp35-cp35m-win32.whl

Download URL asyncpg-0.20.0-cp35-cp35m-win32.whl
Size 1.0 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
cc0882dfd860063d351680494050a92c9915d4693620357cf0d3b56f8153996f
BLAKE2b-256 checksum
How to use checksums
f8d14565a241ff06a8d23b783d671852b551b7c525a4ac8872fe75879feee4b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL asyncpg-0.20.0-cp35-cp35m-manylinux1_x86_64.whl
Size 2.7 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9f82f5ab0db3c081c57bc9a4709891ecb3dccd8ce42a4de86c94e923ecefab1b
BLAKE2b-256 checksum
How to use checksums
92dded3ac7f57b1685ae0bf1ea8c5c76d611be17b51da4792e1918edd618c569
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp35-cp35m-manylinux1_i686.whl

Download URL asyncpg-0.20.0-cp35-cp35m-manylinux1_i686.whl
Size 2.5 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
2a8f85029271c517e79e8068fdc32e37349a3fd45a3b592063dfc19dfa2ddadd
BLAKE2b-256 checksum
How to use checksums
dc5007a64ef94d111ade179fcd2cbd1c326f38a2cc4d3155f5b6708b516593d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release files / asyncpg-0.20.0-cp35-cp35m-macosx_10_13_x86_64.whl

Download URL asyncpg-0.20.0-cp35-cp35m-macosx_10_13_x86_64.whl
Size 1.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
08599fbe81b254a28944cd60c0047f650b51acaa7ad396ae6f44e92d13dc9cb7
BLAKE2b-256 checksum
How to use checksums
2aba30010534cbe228b388ec128075796b5b53c435711c93fc8b9f4dffb496d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.20.0 This release

21 release files

0.8.1

6 release files

0.8.0

6 release files

0.7.0

7 release files

0.6.3

6 release files

0.6.2

4 release files

0.6.1

2 release files

0.5.4

4 release files

0.5.3

4 release files

0.5.2

4 release files

0.5.1

1 release file

0.5.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page