From: Mike Bayer Date: Mon, 11 Mar 2024 23:59:06 +0000 (-0400) Subject: update section be qualified for PGBouncer X-Git-Tag: rel_2_0_29~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a77c42eae271c08848738dd958d547b5308bf3f1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git update section be qualified for PGBouncer the NullPool advice is for PGBouncer only Change-Id: Ib79cae8965435b78fbde6e2d4de5e35fcd2a2f21 (cherry picked from commit f99209583272b65a71c0b4884fd14edcf6577939) --- diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index 4c60c3d832..df2656de2a 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -112,8 +112,8 @@ To disable the prepared statement cache, use a value of zero:: .. _asyncpg_prepared_statement_name: -Prepared Statement Name ------------------------ +Prepared Statement Name with PGBouncer +-------------------------------------- By default, asyncpg enumerates prepared statements in numeric order, which can lead to errors if a name has already been taken for another prepared @@ -128,7 +128,7 @@ a prepared statement is prepared:: from uuid import uuid4 engine = create_async_engine( - "postgresql+asyncpg://user:pass@hostname/dbname", + "postgresql+asyncpg://user:pass@somepgbouncer/dbname", poolclass=NullPool, connect_args={ 'prepared_statement_name_func': lambda: f'__asyncpg_{uuid4()}__', @@ -141,7 +141,7 @@ a prepared statement is prepared:: https://github.com/sqlalchemy/sqlalchemy/issues/6467 -.. warning:: To prevent a buildup of useless prepared statements in +.. warning:: When using PGBouncer, to prevent a buildup of useless prepared statements in your application, it's important to use the :class:`.NullPool` pool class, and to configure PgBouncer to use `DISCARD `_ when returning connections. The DISCARD command is used to release resources held by the db connection,