@@ -18,18 +18,21 @@ of asyncpg at some point in the future.
1818Can 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
2727Can I use dot-notation with :class: `asyncpg.Record `? It looks cleaner.
2828~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929
3030We decided against making :class: `asyncpg.Record ` a named tuple
3131because 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
3538Why 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
5659PostgreSQL server directly, but via
5760`pgbouncer <https://pgbouncer.github.io/ >`_. pgbouncer, when
5861in 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
7081Why do I get ``PostgresSyntaxError `` when using ``expression IN $1 ``?
0 commit comments