From: Daniele Varrazzo Date: Sat, 28 Aug 2021 01:32:42 +0000 (+0200) Subject: Fix shortcuts examples X-Git-Tag: 3.0.beta1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9e5bfad642240fa38b500805bb77868b9178de5;p=thirdparty%2Fpsycopg.git Fix shortcuts examples --- diff --git a/docs/basic/usage.rst b/docs/basic/usage.rst index 83bfa600f..4fc6b2b88 100644 --- a/docs/basic/usage.rst +++ b/docs/basic/usage.rst @@ -110,19 +110,19 @@ exposes a few simple extensions which make the above pattern leaner: .. code:: - # This - cur = conn.execute(...) - - # is equivalent to: + # In Psycopg 2 cur = conn.cursor() cur.execute(...) + # In Psycopg 3 + cur = conn.execute(...) + - The `Cursor.execute()` method returns `!self`. This means that you can chain a fetch operation, such as `~Cursor.fetchone()`, to the `!execute()` call: .. code:: - # This + # In Psycopg 2 cur.execute(...) record = cur.fetchone() @@ -130,8 +130,9 @@ exposes a few simple extensions which make the above pattern leaner: for record in cur: ... - # is equivalent to: + # In Psycopg 3 record = cur.execute(...).fetchone() + for record in cur.execute(...): ...