]> git.ipfire.org Git - thirdparty/psycopg.git/commit
Cursor.copy() made into a context manager
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 15 Nov 2020 01:47:51 +0000 (01:47 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 15 Nov 2020 02:33:34 +0000 (02:33 +0000)
commitbd2130e352c3a2952e9dd68159a5502c0c51d946
tree77c31b5fb7839ec09c31011623ab8fc47371775b
parent922aacfb4e3a5882db01b0f64f7a06bc93601bfc
Cursor.copy() made into a context manager

What was before was a factory function, however that forced to have a
pattern like:

    async with (await cursor.copy()) as copy

Now instead what should be used is:

    async with cursor.copy() as copy

With this change the user pretty much is never exposed anymore to a Copy
object in a non-entered state. This is actually useful because it
reduces the surface of the API: now for instance Copy.finis() can become
a private method.
docs/cursor.rst
docs/usage.rst
psycopg3/psycopg3/cursor.py
tests/test_copy.py
tests/test_copy_async.py
tests/test_sql.py