]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Add instructions for pgbouncer simple query protocol
authorRuben Laguna <ruben.laguna@tele2.com>
Tue, 14 May 2024 13:48:08 +0000 (15:48 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 14 May 2024 15:39:47 +0000 (17:39 +0200)
docs/advanced/cursors.rst

index 8ece1e7e8fc571e9e7aa1aad34982ba182f432d8..fd4191c80203c6ecc07676e3eb15ea1eb911d2e5 100644 (file)
@@ -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  <https://www.pgbouncer.org/usage.html#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