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.

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 requires Python 3.5 and is available on PyPI. Use pip to install it:

$ 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.8.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.8.0
File Size Uploaded
asyncpg-0.8.0.tar.gz 378.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for asyncpg 0.8.0
File
asyncpg-0.8.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
asyncpg-0.8.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
asyncpg-0.8.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
asyncpg-0.8.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
asyncpg-0.8.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: 5.1 MB

Release files / asyncpg-0.8.0.tar.gz

Download URL asyncpg-0.8.0.tar.gz
Size 378.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0b512341c3552641f4aacd45cdf45c1ce7fdd9d01fa873840fc6a81a04f1b67f
BLAKE2b-256 checksum
How to use checksums
5245cf921790d5f1c642cf4f38636adf8ab0ad0f055998925de1a42b6fbe4846
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL asyncpg-0.8.0-cp35-cp35m-win_amd64.whl
Size 573.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c2ad5dde26f3dc787e196dac4fb67e7b23b0a34db1d7fbe4bde015fa37977c62
BLAKE2b-256 checksum
How to use checksums
9dfd0ce2a93ccdf4f8083b0f49b9f0f17fe2dda92ed5da743cfc932031a3b817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

Download URL asyncpg-0.8.0-cp35-cp35m-macosx_10_11_x86_64.whl
Size 830.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64
SHA-256 checksum
How to use checksums
8eb968f261b97f65d626e22d77676fbfe0e86d3fc841db10c95fc3410f791672
BLAKE2b-256 checksum
How to use checksums
be2ac30325aae74500f4fa0bfce829c31f980f774ea8057b5d40ebff9667a0c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.8.1

6 release files

This release

0.8.0 This release

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