Skip to content

Commit 3d0e23f

Browse files
committed
Update README and setup.py to reflect the current state better
1 parent 50f65fb commit 3d0e23f

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

README.rst

+9-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ framework. You can read more about asyncpg in an introductory
1414
`blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
1515

1616
asyncpg requires Python 3.5 or later and is supported for PostgreSQL
17-
versions 9.2 to 12.
17+
versions 9.5 to 13. Older PostgreSQL versions or other databases implementing
18+
the PostgreSQL protocol *may* work, but are not being actively tested.
1819

1920

2021
Documentation
@@ -31,10 +32,11 @@ In our testing asyncpg is, on average, **3x** faster than psycopg2
3132
(and its asyncio variant -- aiopg).
3233

3334
.. image:: performance.png
34-
:target: http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/
35+
:target: https://gistpreview.github.io/?b8eac294ac85da177ff82f784ff2cb60
3536

3637
The above results are a geometric mean of benchmarks obtained with PostgreSQL
37-
`client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_.
38+
`client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_
39+
in November 2020.
3840

3941

4042
Features
@@ -74,7 +76,10 @@ Basic Usage
7476
async def run():
7577
conn = await asyncpg.connect(user='user', password='password',
7678
database='database', host='127.0.0.1')
77-
values = await conn.fetch('''SELECT * FROM mytable''')
79+
values = await conn.fetch(
80+
'SELECT * FROM mytable WHERE id = $1',
81+
10,
82+
)
7883
await conn.close()
7984
8085
loop = asyncio.get_event_loop()

docs/faq.rst

+20-9
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ of asyncpg at some point in the future.
1818
Can I use asyncpg with SQLAlchemy ORM?
1919
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020

21-
Short answer: no. asyncpg uses asynchronous execution model
22-
and API, which is fundamentally incompatible with SQLAlchemy.
23-
However, it is possible to use asyncpg and SQLAlchemy Core
24-
with the help of a third-party adapter, such as asyncpgsa_ or databases_.
21+
Yes. SQLAlchemy version 1.4 and later supports the asyncpg dialect natively.
22+
Please refer to its documentation for details. Older SQLAlchemy versions
23+
may be used in tandem with a third-party adapter such as
24+
asyncpgsa_ or databases_.
2525

2626

2727
Can I use dot-notation with :class:`asyncpg.Record`? It looks cleaner.
2828
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
We decided against making :class:`asyncpg.Record` a named tuple
3131
because we want to keep the ``Record`` method namespace separate
32-
from the column namespace.
32+
from the column namespace. That said, you can provide a custom ``Record``
33+
class that implements dot-notation via the ``record_class`` argument to
34+
:func:`connect() <asyncpg.connection.connect>` or any of the Record-returning
35+
methods.
3336

3437

3538
Why can't I use a :ref:`cursor <asyncpg-api-cursor>` outside of a transaction?
@@ -56,15 +59,23 @@ already exists`` errors, you are most likely not connecting to the
5659
PostgreSQL server directly, but via
5760
`pgbouncer <https://pgbouncer.github.io/>`_. pgbouncer, when
5861
in the ``"transaction"`` or ``"statement"`` pooling mode, does not support
59-
prepared statements. You have two options:
62+
prepared statements. You have several options:
6063

61-
* if you are using pgbouncer for connection pooling to a single server,
64+
* if you are using pgbouncer only to reduce the cost of new connections
65+
(as opposed to using pgbouncer for connection pooling from
66+
a large number of clients in the interest of better scalability),
6267
switch to the :ref:`connection pool <asyncpg-connection-pool>`
6368
functionality provided by asyncpg, it is a much better option for this
6469
purpose;
6570

66-
* if you have no option of avoiding the use of pgbouncer, then you need to
67-
switch pgbouncer's ``pool_mode`` to ``session``.
71+
* disable automatic use of prepared statements by passing
72+
``statement_cache_size=0``
73+
to :func:`asyncpg.connect() <asyncpg.connection.connect>` and
74+
:func:`asyncpg.create_pool() <asyncpg.pool.create_pool>`
75+
(and, obviously, avoid the use of
76+
:meth:`Connection.prepare() <asyncpg.connection.Connection.prepare>`);
77+
78+
* switch pgbouncer's ``pool_mode`` to ``session``.
6879

6980

7081
Why do I get ``PostgresSyntaxError`` when using ``expression IN $1``?

performance.png

5.38 KB
Loading

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from setuptools.command import build_ext as setuptools_build_ext
2626

2727

28-
CYTHON_DEPENDENCY = 'Cython==0.29.20'
28+
CYTHON_DEPENDENCY = 'Cython(>=0.29.20,<0.30.0)'
2929

3030
# Minimal dependencies required to test asyncpg.
3131
TEST_DEPENDENCIES = [
@@ -263,6 +263,7 @@ def finalize_options(self):
263263
'Programming Language :: Python :: 3.6',
264264
'Programming Language :: Python :: 3.7',
265265
'Programming Language :: Python :: 3.8',
266+
'Programming Language :: Python :: 3.9',
266267
'Programming Language :: Python :: Implementation :: CPython',
267268
'Topic :: Database :: Front-Ends',
268269
],

0 commit comments

Comments
 (0)