Skip to main content

An asyncio PostgreSQL driver

Project description

GitHub Actions status 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.5 to 13. Older PostgreSQL versions or other databases implementing the PostgreSQL protocol may work, but are not being actively tested.

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

https://raw.githubusercontent.com/MagicStack/asyncpg/master/performance.png

The above results are a geometric mean of benchmarks obtained with PostgreSQL client driver benchmarking toolbench in November 2020 (click on the chart to see full details).

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 WHERE id = $1',
        10,
    )
    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 Distribution

asyncpg-0.23.0.tar.gz (775.1 kB view details)

Uploaded Source

Built Distributions

asyncpg-0.23.0-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

asyncpg-0.23.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

asyncpg-0.23.0-cp39-cp39-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

asyncpg-0.23.0-cp38-cp38-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

asyncpg-0.23.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

asyncpg-0.23.0-cp38-cp38-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

asyncpg-0.23.0-cp37-cp37m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.7m Windows x86-64

asyncpg-0.23.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

asyncpg-0.23.0-cp37-cp37m-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

asyncpg-0.23.0-cp36-cp36m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

asyncpg-0.23.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

asyncpg-0.23.0-cp36-cp36m-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

asyncpg-0.23.0-cp35-cp35m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.5m manylinux: glibc 2.5+ x86-64

asyncpg-0.23.0-cp35-cp35m-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.5m macOS 10.14+ x86-64

File details

Details for the file asyncpg-0.23.0.tar.gz.

File metadata

  • Download URL: asyncpg-0.23.0.tar.gz
  • Upload date:
  • Size: 775.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0.tar.gz
Algorithm Hash digest
SHA256 812dafa4c9e264d430adcc0f5899f0dc5413155a605088af696f952d72d36b5e
MD5 2d82ec693450635de37b5ddbaf73cbd9
BLAKE2b-256 97b0acacd8496670b24bad90b92c105fd2f66e83051bf5e23b978a059e5f9608

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ceedd46f569f5efb8b4def3d1dd6a0d85e1a44722608d68aa1d2d0f8693c1bff
MD5 12d73a911fbd279728479eb9627e8e47
BLAKE2b-256 93214a391ce3588b0caf05fbf5fe1dcad02e87753528164eafc9bc54ee949cb5

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.23.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bd6e1f3db9889b5d987b6a1cab49c5b5070756290f3420a4c7a63d942d73ab69
MD5 aa6154934513c42a54da96781e671b32
BLAKE2b-256 c37affa6dc212ae9578a855f190ef0b0c02c6fc6f6152b6aa8c1b586d718d3be

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 98bef539326408da0c2ed0714432e4c79e345820697914318013588ff235b581
MD5 7d96f5f31048468022ba87afa5be9bd5
BLAKE2b-256 916d84ddf23d3c5a022d02c00182bae9d45446a4e4bc45571ad47cfac8b810b3

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 df84f3e93cd08cb31a252510a2e7be4bb15e6dff8a06d91f94c057a305d5d55d
MD5 42dbec0336bf1a523bf7d85e9bcdf624
BLAKE2b-256 91ee4447aac4a4ca2632a9a6a9abc8e7fb2e0fb04c6031295ac90d1c9cf9957a

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.23.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 43c44d323c3bd6514fbe6a892ccfdc551259bd92e98dd34ad1a52bad8c7974f3
MD5 7ab8cb6e310bc4aea0fec5a8606c38c5
BLAKE2b-256 a517d9b6842bb1171cca9587e6f003e8b3efc9f47c2d09b4e5fad5dd7bf29b5b

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a19429d480a387346ae74b38da20e8da004337f14e5066f4bd6a10a8bbe74d3c
MD5 9118aef564134fdd2926494c27b27f60
BLAKE2b-256 3738e0de1d675c0191be00131410884e0d0b9149f878de686e12c410c47cc126

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b784138e69752aaa905b60c5a07a891445706824358fe1440d47113db72c8946
MD5 c23ed4cd41344b7f81fe8d458730f65c
BLAKE2b-256 8845ea5e14413d46a8e107b62ac1f373a629ae371ab10a5918f4ada2bb140099

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.23.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2710b5740cbd572e0fddc20986a44707f05d3f84e29fab72abe87fb8c2fc6885
MD5 b38c5eb34507c7d704fa924a73bb2fca
BLAKE2b-256 6ec1162ee1458c80e451b772e5232370d0398213b6bb65e06586661c8f7a86a5

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a2031df7573c80186339039cc2c4e684648fea5eaa9537c24f18c509bda2cd3f
MD5 ef44a7375c0cbb14aa47d87631e17eeb
BLAKE2b-256 c98625a68ea156898ecd09dd3a80fc5f2dfbf5cc1f226561604416eb436857d5

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a88654ede00596a7bdaa08066ff0505aed491f790621dcdb478066c7ddfd1a3d
MD5 b9238703eca9964267ee03f4cc19cd8a
BLAKE2b-256 1af13d01a191c1c512f3a22b289f7edcd86b195f168ae1499445a33ffc875197

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.23.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d82d94badd34c8adbc5c85b85085317444cd9e062fc8b956221b34ba4c823b56
MD5 5961cfac2074f38588eb6abca7135669
BLAKE2b-256 f0bad93d6992ff1225cf8eae08479a3eab17f6814620570671e470e7f5561ddf

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 11102ac2febbc208427f39e4555537ecf188bd70ef7b285fc92c6c16b748b4c6
MD5 499d65347029cf48d011e10bd83e21fd
BLAKE2b-256 6bf9087ce60fdc8b4d2e40e3de3560900aab0ee9b7098df068a0e10b3dc696cb

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp35-cp35m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for asyncpg-0.23.0-cp35-cp35m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 255839c8c52ebd72d6d0159564d7eb8f70fcf6cc9ce7cdc7e98328fd3279bf52
MD5 e0ae931abb4c113e53d4fba3e1c76fc5
BLAKE2b-256 b1200bccd193bc04d8aead8410413709fc063eb3faec2a99781d2767ab310c27

See more details on using hashes here.

File details

Details for the file asyncpg-0.23.0-cp35-cp35m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.23.0-cp35-cp35m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.5m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for asyncpg-0.23.0-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f86378bbfbec7334af03bad4d5fd432149286665ecc8bfbcb7135da56b15d34b
MD5 3b5a8d188fca4686db092a18874c9604
BLAKE2b-256 02a0cc5b1302ae1728d7c34089f7b481263263a167a55e52b4dadf5e03cd42fa

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