From: Ruben Laguna Date: Tue, 14 May 2024 13:48:08 +0000 (+0200) Subject: Add instructions for pgbouncer simple query protocol X-Git-Tag: 3.2.0~30 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e58f1d3f68f16d049a2eef8d05d992f552163fdf;p=thirdparty%2Fpsycopg.git Add instructions for pgbouncer simple query protocol --- diff --git a/docs/advanced/cursors.rst b/docs/advanced/cursors.rst index 8ece1e7e8..fd4191c80 100644 --- a/docs/advanced/cursors.rst +++ b/docs/advanced/cursors.rst @@ -125,6 +125,23 @@ as argument. conn = psycopg.connect(DSN) cur = psycopg.ClientCursor(conn) + +You can also use `~ClientCursor` with autocommit mode to disable Extended +Query Protocol and use Simple Query Protocol instead. This is useful for +example when issuing `SHOW STATS` to a `pgbouncer` for example, since the +`Pgbouncer Admin Console `_ +only support Simple Query Protocol. + +.. code:: python + + from psycopg import connect, ClientCursor + + conn = psycopg.connect(DSN, cursor_factory=ClientCursor, autocommit=True) + cur = conn.cursor() + cur.execute("SHOW STATS") + cur.fetchall() + + .. warning:: Client-side cursors don't support :ref:`binary parameters and return