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.1

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.1
File Size Uploaded
asyncpg-0.20.1.tar.gz 734.3 kB Details

Built distributions (wheels)

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

Release files / asyncpg-0.20.1.tar.gz

Download URL asyncpg-0.20.1.tar.gz
Size 734.3 kB
Tags Source
SHA-256 checksum
How to use checksums
394bf19bdddbba07a38cd6fb526ebf66e120444d6b3097332b78efd5b26495b0
BLAKE2b-256 checksum
How to use checksums
fdb0f55fd9262faca7e93af3b4f5f677a16dcc380545d1ae76124f09bc6b58ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-cp38-cp38-win_amd64.whl
Size 1.1 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
2af6a5a705accd36e13292ea43d08c20b15e52d684beb522cb3a7d3c9c8f3f48
BLAKE2b-256 checksum
How to use checksums
3b3ab8a93cc3cf439260c48ea5ce427657d27b45de3fd066bee9ead33a678065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-cp38-cp38-win32.whl
Size 1.0 MB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
e39aac2b3a2f839ce65aa255ce416de899c58b7d38d601d24ca35558e13b48e3
BLAKE2b-256 checksum
How to use checksums
6cb24d84e5d126d1de5c23adc7d6c98d1cc8bb64c9c2ca413faee0f3cb2946bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
a9e6fd6f0f9e8bd77e9a4e1ef9a4f83a80674d9136a754ae3603e915da96b627
BLAKE2b-256 checksum
How to use checksums
eeaab7d71b4ecfe7252ac279ce58ab0bbe3b0ca8e51b0aad408e559034268e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
a981500bf6947926e53c48f4d60ae080af1b4ad7fa78e363465a5b5ad4f2b65e
BLAKE2b-256 checksum
How to use checksums
efe21c98ceb4a323ae144fedd0e3101089e3fbd846840cf928a720f2c83f71aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
391aea89871df8c1560750af6c7170f2772c2d133b34772acf3637e3cf4db93e
BLAKE2b-256 checksum
How to use checksums
f9045b626ef6cc3ab46a4e7b55ae1d90aa212610209c306306e1c4cff11a2ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
74510234c294c6a6767089ba9c938f09a491426c24405634eb357bd91dffd734
BLAKE2b-256 checksum
How to use checksums
981b98cb955ac3e087d0cfa3c48b6402191c45703ed3c9a096005c0bfcc0a9bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
da238592235717419a6a7b5edc8564da410ebfd056ca4ecc41e70b1b5df86fba
BLAKE2b-256 checksum
How to use checksums
d26af3bc7af2c37fbdf73448397878edc87af8530f41bbd3e4635ed82303d75b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-cp37-cp37m-manylinux1_x86_64.whl
Size 2.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ba90d3578bc6dddcbce461875672fd9bdb34f0b8215b68612dd3b65a956ff51c
BLAKE2b-256 checksum
How to use checksums
b835866af60f23031933b99cd867fdfce54c2fbc0d35963b41eeaae95b39efe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
ad5ba062e09673b1a4b8d0facaf5a6d9719bf7b337440d10b07fe994d90a9552
BLAKE2b-256 checksum
How to use checksums
9dd9de0de0dc4125fc58e78a993c612047e76469debbf9d320792537fdd4783e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
0c336903c3b08e970f8af2f606332f1738dba156bca83ed0467dc2f5c70da796
BLAKE2b-256 checksum
How to use checksums
56c0d8b8d65ff1591b90a33880f8031f6d45b4e99d2025aeaeab37ba7d7b6cba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
57666dfae38f4dbf84ffbf0c5c0f78733fef0e8e083230275dcb9ccad1d5ee09
BLAKE2b-256 checksum
How to use checksums
5c06774ebfe173da968178dcd775572f463382f93dc57caee0916beaad0f5c35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
5664d1bd8abe64fc60a0e701eb85fa1d8c9a4a8018a5a59164d27238f2caf395
BLAKE2b-256 checksum
How to use checksums
fdab2d66b3e72389cbfe5de42c8c59510ee036a03c9a0ad50b4aef3f136eecee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
c773c7dbe2f4d3ebc9e3030e94303e45d6742e6c2fc25da0c46a56ea3d83caeb
BLAKE2b-256 checksum
How to use checksums
c718fb606a5fca7188a219af7b6f1e4c2f03b0b2fc3a1af7860990c6f3b407d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
058baec9d6b75612412baa872a1aa47317d0ff88c318a49f9c4a2389043d5a8d
BLAKE2b-256 checksum
How to use checksums
e79edc28c9bfc58867f11eabe86cca2d79405fbaeefcad564105979c8a9f9226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-cp36-cp36m-macosx_10_13_x86_64.whl
Size 1.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
95cd2df61ee00b789bdcd04a080e6d9188693b841db2bf9a87ebaed9e53147e0
BLAKE2b-256 checksum
How to use checksums
c4953e6ddde58a51fc0fd04360649e2d30d403bb1a01aff9589bda84711bbbd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
25edb0b947eb632b6b53e5a4b36cba5677297bb34cbaba270019714d0a5fed76
BLAKE2b-256 checksum
How to use checksums
9fb8fa6fb92c91fc8ecbd96494d3210b683dab9c6f1d7bdae68cb5db4a46ce68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
ec6e7046c98730cb2ba4df41387e10cb8963a3ac2918f69ae416f8aab9ca7b1b
BLAKE2b-256 checksum
How to use checksums
0c66e2c660fac5886e3408daf51ab8df00d88cad43a8ee88c8b26519a3a0b970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
1388caa456070dab102be874205e3ae8fd1de2577d5de9fa22e65ba5c0f8b110
BLAKE2b-256 checksum
How to use checksums
971c35ecbf05f10a69b75dc5cce2e94b42120cade0817593d740d49fc1deeced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
f0c9719ac00615f097fe91082b785bce36dbf02a5ec4115ede0ebfd2cd9500cb
BLAKE2b-256 checksum
How to use checksums
890a4f1d48b83522bb708a8e96486d98fb66cfcaabfe0737f53f8630d0a4bbd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

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

Download URL asyncpg-0.20.1-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
f7184689177eeb5a11fa1b2baf3f6f2e26bfd7a85acf4de1a3adbd0867d7c0e2
BLAKE2b-256 checksum
How to use checksums
c3fa468938a2e5136b8ac3710f16f96950c47615c72cc64fe0527f9fa93440ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.20.1 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