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.22.0.tar.gz (770.3 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

asyncpg-0.22.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.22.0-cp38-cp38-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

asyncpg-0.22.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.22.0-cp37-cp37m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

asyncpg-0.22.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.22.0-cp36-cp36m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

asyncpg-0.22.0-cp36-cp36m-macosx_10_14_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

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

Uploaded CPython 3.5m

asyncpg-0.22.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.22.0.tar.gz.

File metadata

  • Download URL: asyncpg-0.22.0.tar.gz
  • Upload date:
  • Size: 770.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0.tar.gz
Algorithm Hash digest
SHA256 348ad471d9bdd77f0609a00c860142f47c81c9123f4064d13d65c8569415d802
MD5 d6636fac70ec5bf7b92e041cc70e96c5
BLAKE2b-256 fe801bee9b4bd29faa8bd5c9b87f252788aeaea645d3e7860ffe1c3dfcc3eb0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2e3875c82ae609b21e562e6befdc35e52c4290e49d03e7529275d59a0595ca97
MD5 f2ceb105fc6b9ea69819debc7d767447
BLAKE2b-256 54120e96ea40f13de4072ae732a980a9eb63bb3852345aa856a94516766649b7

See more details on using hashes here.

File details

Details for the file asyncpg-0.22.0-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.22.0-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2cb730241dfe650b9626eae00490cca4cfeb00871ed8b8f389f3a4507b328683
MD5 e2381c58e4c948c1f42728d9b4fe0e20
BLAKE2b-256 74ef5e3aa33ade8d2e8878d9f747d60cbe90f628826d86b93242a357cc250571

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1bbe5e829de506c743cbd5240b3722e487c53669a5f1e159abcc3b92a64a985e
MD5 64714d09240a766e73b5442c756a5f85
BLAKE2b-256 35357f3c43efb241396d41ed3f20a208ce1898bcec917560bc65c01c00a671cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e7a67fb0244e4a5b3baaa40092d0efd642da032b5e891d75947dab993b47d925
MD5 31656ba01abf7c02af80041f0dca9300
BLAKE2b-256 7b897eb0d2668e0578f2f128c5d8905552453669236925902b86b635b164c56f

See more details on using hashes here.

File details

Details for the file asyncpg-0.22.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.22.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 062e4ff80e68fe56066c44a8c51989a98785904bf86f49058a242a5887be6ce3
MD5 0638e63b835ac8fe3c9b8e1b959030ae
BLAKE2b-256 d29b7c0862925f4322df7258ed87536efad8433310ea6517e8d24d6f4d4d32d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 82e23ba5b37c0c7ee96f290a95cbf9815b2d29b302e8b9c4af1de9b7759fd27b
MD5 34175e9dd86422878ed160a932e1e6da
BLAKE2b-256 d50a9554c0bbaa232811f2a345a5a1949b01f1427262fcedfd05f9fa64a75b2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1f514b13bc54bde65db6cd1d0832ae27f21093e3cb66f741e078fab77768971c
MD5 ffcc63faed2beb2d3fa8acb3e32cb4e8
BLAKE2b-256 e1a9ddb7c126c9b56dc6b5acc6c4a85731ea2df475a7e93225d9615666282415

See more details on using hashes here.

File details

Details for the file asyncpg-0.22.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.22.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f1df7cfd12ef484210717e7827cc2d4d550b16a1b4dd4566c93914c7a2259352
MD5 14f46581fb9b48cc1af4f703c0a7126c
BLAKE2b-256 33be6573e86d19c7954c882d6172278edfb1cbed5e9cba742384a988781421f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1d3efdec14f3fbcc665b77619f8b420564f98b89632a21694be2101dafa6bcf2
MD5 0a674130481b3eb36fdcfc626672464f
BLAKE2b-256 d085e66a6723022ec7a6bce77944b0cd44686671fc4aa93495185932d0383ba0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b37efafbbec505287bd1499a88f4b59ff2b470709a1d8f7e4db198d3e2c5a2c4
MD5 7441426ff0111ae539ec40d2c9d161c7
BLAKE2b-256 11917065196c1a9e981481eeffeb5195b4a003676a42bf6115052589f9890e92

See more details on using hashes here.

File details

Details for the file asyncpg-0.22.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.22.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0f4604a88386d68c46bf7b50c201a9718515b0d2df6d5e9ce024d78ed0f7189c
MD5 dbf39210510c4bf8f5553d0fa79a1a78
BLAKE2b-256 126613b1e14584ae4e8bdf754941195ab75e6d4f84f9bc234029ed48093de3a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d1cb6e5b58a4e017335f2a1886e153a32bd213ffa9f7129ee5aced2a7210fa3c
MD5 8f68af8db08ba3d669e1d8fbb81ea8e2
BLAKE2b-256 3c6a7c5364256fa9ff70c894b36b24e2e6aee3ba721c70844847ec1dd65e1e44

See more details on using hashes here.

File details

Details for the file asyncpg-0.22.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: asyncpg-0.22.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3af9a8511569983481b5cf94db17b7cbecd06b5398aac9c82e4acb69bb1f4090
MD5 e2ab1c3c4da518a2c9e7ac8ee2de28ef
BLAKE2b-256 9377ab545bcaa7008f2c682f9c6f9f0e513c9d64797d6574c5921f54a14c889f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncpg-0.22.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.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for asyncpg-0.22.0-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ccd75cfb4710c7e8debc19516e2e1d4c9863cce3f7a45a3822980d04b16f4fdd
MD5 8b7eb4f166d26c5daa1d77af9b8b979d
BLAKE2b-256 0ab6d45cb2155fee7e15f9d3ccad11cf9ec2c3c1ef25857c9e5cb831f4b35a23

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