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

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.12.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.12.0
File Size Uploaded
asyncpg-0.12.0.tar.gz 518.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for asyncpg 0.12.0
File
asyncpg-0.12.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
asyncpg-0.12.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
asyncpg-0.12.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.12.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.12.0-cp36-cp36m-macosx_10_12_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.12+ x86-64 Details
asyncpg-0.12.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
asyncpg-0.12.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
asyncpg-0.12.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.12.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.12.0-cp35-cp35m-macosx_10_11_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64 Details

Total release size: 12.8 MB

Release files / asyncpg-0.12.0.tar.gz

Download URL asyncpg-0.12.0.tar.gz
Size 518.1 kB
Tags Source
SHA-256 checksum
How to use checksums
729e9ca808550bc3aad6e6266ea71278faadeed726a9dc72c6d203c1df0a737f
BLAKE2b-256 checksum
How to use checksums
742477533aa7e4a4b7ac4020832153a9ece48bc165abb1447e8b030305754112
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp36-cp36m-win_amd64.whl
Size 772.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
09de06571b9a3d3952f4f3af51616d6147175e71ab07a15fb45c346b34fa15cd
BLAKE2b-256 checksum
How to use checksums
3c0ef560b4789cdfd9173a86a53c42a014ea1e2a42b680091afce2a6230d9b1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp36-cp36m-win32.whl
Size 726.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
08826af6a695c9ddc0379389306cde3cea791ef43e6ddd487730434c3f0739a5
BLAKE2b-256 checksum
How to use checksums
bde4b325b866ca0718b6828f134eb2433caec3386e6b56dada1ff3a4cbaf5e52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp36-cp36m-manylinux1_x86_64.whl
Size 2.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
f1e3c025360d6dbbb4d02d03754dbe5abc3417b0d0f199f2fa07d618e6269c88
BLAKE2b-256 checksum
How to use checksums
5637bc6422d9abc0495d57afab73b16c4b886c536fb84edcbb319da8999db196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp36-cp36m-manylinux1_i686.whl
Size 1.9 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
497a34634119292081f5af51fcbeee5664bd2a8732f995da27eeec703987c479
BLAKE2b-256 checksum
How to use checksums
9754d62762ee0bd79834bfed4121605a6db8fa5bdb8b944a86f28ec7731d9923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / asyncpg-0.12.0-cp36-cp36m-macosx_10_12_x86_64.whl

Download URL asyncpg-0.12.0-cp36-cp36m-macosx_10_12_x86_64.whl
Size 850.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
905640bb67a1aa1d2520337a0efa6f2c20c63239844e2f5b008fc3bf33789b85
BLAKE2b-256 checksum
How to use checksums
456dd451d88106d8eddf3d5b0313d7befeabbfbee96269b5b0ef815938b0585c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp35-cp35m-win_amd64.whl
Size 762.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0d0439d7d67aa078faf8dc366d4c2127c755e1af0d13cbaf481a2a74e24a07bc
BLAKE2b-256 checksum
How to use checksums
aa4056165b1fa8b4febd2c2db118ef08caada298fac4fd3dab4dfe4aa2651591
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp35-cp35m-win32.whl
Size 719.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
cb3a198a9ab291cd0a710a2fd604d64a3154953dfff84cc0c17ebffdbe217bc1
BLAKE2b-256 checksum
How to use checksums
1b091cedf1e28e863aef61da01af4d322a9677dc1a83b09579199c5a1cd22108
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp35-cp35m-manylinux1_x86_64.whl
Size 1.9 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
59c45125e569ab9a7a96fd4476e07deab8719c214991210090c37150a5157fa6
BLAKE2b-256 checksum
How to use checksums
dc5ab319b43d6bcc3ce4e3407b2eb3297e46d51f8797d0b224fdb5af0eb49c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.12.0-cp35-cp35m-manylinux1_i686.whl
Size 1.8 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
702d6ae74035854e3754a7fc508d49adec54a34026eaa39ab6938402a73df730
BLAKE2b-256 checksum
How to use checksums
c43b1a68f4f08e2921c17c255acb32011184de0f546fdf24085ae8caa1c7b262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / asyncpg-0.12.0-cp35-cp35m-macosx_10_11_x86_64.whl

Download URL asyncpg-0.12.0-cp35-cp35m-macosx_10_11_x86_64.whl
Size 876.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64
SHA-256 checksum
How to use checksums
0a07fc0178b080abd097248d89b0ea400f5caaa95a41d91e9ffea5eb8286c426
BLAKE2b-256 checksum
How to use checksums
7dacb3cad3dfa039fe809f5451d32460a53868c3a4ddcdfe5d1ad4457cec5595
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.12.0 This release

11 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