]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Move "from psycopg2" docs page under basic
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 14 Jul 2021 00:46:50 +0000 (02:46 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 14 Jul 2021 00:46:50 +0000 (02:46 +0200)
And tweak it a bit.

docs/basic/from_pg2.rst [moved from docs/from_pg2.rst with 71% similarity]
docs/basic/index.rst
docs/index.rst

similarity index 71%
rename from docs/from_pg2.rst
rename to docs/basic/from_pg2.rst
index 765d716389254f45fa3433fc58bf77ef201b26ce..6e569061ac641a681f697ac044e57d645b54883d 100644 (file)
@@ -1,6 +1,9 @@
 .. index::
     pair: psycopg2; Differences
 
+.. currentmodule:: psycopg
+
+
 Differences from ``psycopg2``
 =============================
 
@@ -62,8 +65,14 @@ The adaptation system has been completely rewritten, in order to address
 server-side parameters adaptation, but also to consider performance,
 flexibility, ease of customization.
 
-Builtin data types should work as expected; if you have wrapped a custom data
-type you should check the :ref:`adaptation` topic.
+The behaviour with builtin data should be as expected; if you have customised
+the way to adapt data, or you have your own extension types, you should look
+at the new objects involved in adaptation.
+
+.. seealso::
+
+    - :ref:`types-adaptation` for the basic behaviour.
+    - :ref:`adaptation` for more advanced use.
 
 
 .. _diff-copy:
@@ -75,12 +84,12 @@ Copy is no more file-based
 PostgreSQL :sql:`COPY`. The interface doesn't make easy to load
 dynamically-generated data to the database.
 
-There is now a single `~psycopg.Cursor.copy()` method, which is similar to
+There is now a single `~Cursor.copy()` method, which is similar to
 `!psycopg2` `!copy_expert()` in accepting a free-form :sql:`COPY` command and
 returns an object to read/write data, block-wise or record-wise. The different
 usage pattern also enables :sql:`COPY` to be used in async interactions.
 
-See :ref:`copy` for the details.
+.. seealso:: See :ref:`copy` for the details.
 
 
 .. _diff-with:
@@ -88,11 +97,20 @@ See :ref:`copy` for the details.
 ``with`` connection
 -------------------
 
-When the connection is used as context manager, at the end of the context
-the connection will be closed. In `!psycopg2` only the transaction is closed,
-so a connection can be used in several contexts, but the behaviour is
-surprising for people used to several other Python classes wrapping
-resources, such as files.
+In `!psycopg2`, using the syntax :ref:`with connection <pg2:with>`,
+only the transaction is closed, not the connection. This behaviour is
+surprising for people used to several other Python classes wrapping resources,
+such as files.
+
+In psycopg3, using :ref:`with connection <with-connection>` will close the
+connection at the end of the `!with` block, making handling the connection
+resources more familiar.
+
+In order to manage transactions as blocks you can use the
+`Connection.transaction()` method, which allows for finer control, for
+instance to use nested transactions.
+
+.. seealso:: See :ref:`transaction-block` for details.
 
 
 .. _diff-callproc:
@@ -100,11 +118,10 @@ resources, such as files.
 ``callproc()`` is gone
 ----------------------
 
-`cursor.callproc()` is not implemented. The method has a simplistic
-semantic which doesn't account for PostgreSQL positional parameters,
-procedures, set-returning functions. Use a normal
-`~psycopg.Cursor.execute()` with :sql:`SELECT function_name(...)` or
-:sql:`CALL procedure_name(...)` instead.
+`cursor.callproc()` is not implemented. The method has a simplistic semantic
+which doesn't account for PostgreSQL positional parameters, procedures,
+set-returning functions... Use a normal `~Cursor.execute()` with :sql:`SELECT
+function_name(...)` or :sql:`CALL procedure_name(...)` instead.
 
 
 What's new in Psycopg 3
index 32f04e1eba033a7083470d3fd017d7c0bd215fce..33f78ff9a04ffc15bc36eb575e71f4156961ea78 100644 (file)
@@ -17,3 +17,4 @@ the database <usage>` or :ref:`loading data using COPY <copy>`.
     adapt
     transactions
     copy
+    from_pg2
index 5ec0769c5ac7ffc6c37a04540a471e67d8b54869..f4c4a1752dd0a7b2756550450d56936827226492 100644 (file)
@@ -29,7 +29,6 @@ Documentation
     basic/index
     advanced/index
     api/index
-    from_pg2
 
 
 Indices and tables