]> 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>
Mon, 16 Nov 2020 04:01:14 +0000 (04:01 +0000)
commitf738b2b6b9e7ef2221179fdd0cc1a1abd3d39ea6
tree4851b601bb71ab78a8090f51f64128da9afd33b0
parent1384ff1683d66b9c207c68a224e2498618b862f3
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