Skip to main content

asyncpg – A fast PostgreSQL Database Client Library for Python/asyncio

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.

Metadata

Release files for asyncpg 0.19.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.19.0
File Size Uploaded Provenance Actions
asyncpg-0.19.0.tar.gz 703.1 kB Without provenance Details for asyncpg-0.19.0.tar.gz

Built distributions (wheels)

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

Total release size: 25.3 MB

Release files / asyncpg-0.19.0.tar.gz

Download URL asyncpg-0.19.0.tar.gz
Size 703.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b253bbbe42eba8e00ad63939ff9d43a5f74e26a4e8f883de867920feb4a9e36a
BLAKE2b-256 checksum
How to use checksums
d4f561d0fda0903a62884b5a11b598b7d12f8f0d66aeeb4b019f3e3d2548f396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp37-cp37m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0527cca24a1bb90b7872867518f25f51a431116075bebbe86149fef593630736
BLAKE2b-256 checksum
How to use checksums
4a73df867f59d58a40ac807846f04d18b946401138562cb393252d4a5a4f2730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp37-cp37m-win32.whl
Size 981.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
16c2accafda9410fd7e8ee561c2bcd1d3141118be81dc9eccc4e671877fecb72
BLAKE2b-256 checksum
How to use checksums
67e8ea8c0e3254e74f5ccfde4d2f2c1f585e2658dc1e7c3393688cafec361752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp37-cp37m-manylinux1_x86_64.whl
Size 2.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
6a9d9824c29a72dc109b9f9e7916c36bbb6ed15e1f3154aa976ac776caf9ad88
BLAKE2b-256 checksum
How to use checksums
59e7aaf05ef85c7eefa57743015723aba9b51bd14023201a496f590ca97248d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp37-cp37m-manylinux1_i686.whl
Size 2.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
cebf06ac15626f3ccb6a537fe593460cdd581bf1aa33dbf3068a21dbef7e393a
BLAKE2b-256 checksum
How to use checksums
a8a8cdb3b9fe82431d75c18a2b41368a710110a0643819d2f78d7595d74dfc01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.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
d3ac4751ae5f77fc646cfeb3f9180f2561eb0876a6b7619cb4e4e290e3432811
BLAKE2b-256 checksum
How to use checksums
eb6feeea98476852be2cba5f6a822cc4f216662a5df0b58ab04b2b54202d4644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp36-cp36m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
35ce817f4a1cef966434e564b69e760d98f0fc2bac73c8786058bd6136ed304e
BLAKE2b-256 checksum
How to use checksums
9058678befb37066cea5e0f8f6560755aba682faca51bcff1b010c8c2aef9bbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp36-cp36m-win32.whl
Size 982.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
45254bc128b175cec75c1cbc64de77bdf5593cbff4cdc58c4ca810878ddfe00b
BLAKE2b-256 checksum
How to use checksums
cc5c69bab654f59809e72bd3d1670f9271e882e43dc275ffc57a34e4d0e54e3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp36-cp36m-manylinux1_x86_64.whl
Size 2.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ccad6b5a59b1c27623c48a840d1f6024994551f27ca0d6c253f64004eaf8a3e6
BLAKE2b-256 checksum
How to use checksums
9f2ed59120bedcfca6c896b4edc2efedacbab157a0faef5db2fb3b00d294c3b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp36-cp36m-manylinux1_i686.whl
Size 2.5 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
e41c8ef26019c27f76cb280dfebad23f84af99ac846b19bcaea06f1b2a2f5fce
BLAKE2b-256 checksum
How to use checksums
3fd710327f00d8b59b779fa4febaa0f86466e16c5f08d59afd4ca38c812f8258
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.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
8c5a9d6573940fe81de36af78459988b5672e427e95667323fe7dfd97f00cd09
BLAKE2b-256 checksum
How to use checksums
20e57bdedc2b0f9a99800089bd7476a81667b85eb3a57a04aea582caaf4be1e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp35-cp35m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8992efcda3022e82966857989c999d5da0e9fc76394f36099700ce544ef39621
BLAKE2b-256 checksum
How to use checksums
b1f1d1b7854a0dacb6c54ba5088a0fed3799137db6fbb955c1f613718d63b9ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp35-cp35m-win32.whl
Size 966.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
aab3a90dba30fe9017b5326727b505e18fe024c2e205655d52e85f9b24f5b2ab
BLAKE2b-256 checksum
How to use checksums
b9d832b83b5a5335a7afdcf82deaf2f64e7b0808a9d7b5db667fd63941c9abaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp35-cp35m-manylinux1_x86_64.whl
Size 2.6 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
426eb401b760abb0ce670d1d09201f1ae5a58355d272c413d1f7d7b6e354b00d
BLAKE2b-256 checksum
How to use checksums
bd707f6f42a66b31e1cc608edab89fb897e44559b34c9cffbeaf32db9e3939f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp35-cp35m-manylinux1_i686.whl
Size 2.4 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
f3e9863510b4e54ade1d20af5ef18901dea44e4fd7259db516b73810c0a1ad2e
BLAKE2b-256 checksum
How to use checksums
d75a0f2134fe874c21b803d1ba22742ae902a7de5dede5c6a45434f21aef7a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

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

Download URL asyncpg-0.19.0-cp35-cp35m-macosx_10_13_x86_64.whl
Size 1.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
81431aac651d0386f483697d831cd9cb6efa816fd08dcedf0387602f52c1d4d0
BLAKE2b-256 checksum
How to use checksums
f5aec2e6b1ccc699ee918b726e8739be91dce9028b75feea5a26f5e375946c0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

Security for asyncpg 0.19.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.19.0 This release

16 release files No provenance

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