Skip to content
Snippets Groups Projects
Commit 955c001f authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

Migrate to psycopg3

This replace the previous usage of psycopg2. Beware that MR is various
dependencies needs to be landed and released accordingly.

We upgrade imports and various function and class names

Data type wrapping seems significantly simpler in psycopg3 so we can drop code
related to it.

Adding various typing information to help catch bug and make mypy happy.

We use context manager more to make sure the connection is getting properly
closed (and not just the cursors) as psycopg3 seems more sensitive to this.

We have to jump through quite hacky hoops to get a connection
information with a (reinjected) password in it. I am a bit nervous about
it. Especially as the test does not seems to exercise this case.

We drop the `execute_values_generator` from core.db as psycopg3 has better
capability in that regards that make it unnecessary in more situation. We have
a reimplementation of it compatible with psycopg3 in swh-storage (part of the
series migrating it to psycopg3)

We are dropping call to "psycopg2.extras.register_default_jsonb" call in test,
as this seems to no longer be necessary in psycopg3.

We are dropping the call to "psycopg.extras.register_uuid" as it no
longer seems useful

We are dropping the adapter for memory view as psycopg3 already do the
right thing:
https://www.psycopg.org/psycopg3/docs/basic/adapt.html#binary-adaptation

We use proper value swapping to set the config.
parent ee074f0e
No related branches found
No related tags found
1 merge request!382migrating to psycopg3
Pipeline #14181 passed