Bug 12953 - Consider moving from psycopg2 to psycopg3
Summary: Consider moving from psycopg2 to psycopg3
Status: CLOSED FIXED
Alias: None
Product: Location Database
Classification: Unclassified
Component: libloc (show other bugs)
Version: unspecified
Hardware: unspecified Unspecified
: - Unknown - - Unknown -
Assignee: Michael Tremer
QA Contact: Peter Müller
URL:
Keywords: NewFeature
Depends on:
Blocks:
 
Reported: 2022-10-13 12:50 UTC by Petr Pisar
Modified: 2024-03-04 13:26 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2022-10-13 12:50:12 UTC
src/python/location/database.py imports psycopg2. There is a project called psycopg3 from the same author <https://www.psycopg.org/psycopg3/>.

Please consider porting libloc to pyscopg3. One can imagine that in the future psycopg2 will be abandoned in favour of psycopg3. And than distribution will start removing psycopg2 A porting guide <https://www.varrazzo.com/blog/2020/11/07/psycopg3-adaptation/>.
Comment 1 Michael Tremer 2022-10-17 14:06:32 UTC
Hello Petr,

the database.py file is kind of a standard file that we use in many projects. Generally it is a simple wrapper to make the database API a little bit easier to use and more Pythonic. It is not very complicated and does not rely on any special features as far as I can see.

psycopg3 looks a lot more complicated than version 2, but I will probably take the time at some point to migrate - hopefully being able to incorporate any async stuff, too.

However, that would be a low priority (compared to the other things on my TODO list) for now.

Please keep me updated if psycopg2 is suddenly nearing its EOL.
Comment 2 Michael Tremer 2024-03-04 12:39:45 UTC
http://git.ipfire.org/?p=people/ms/libloc.git;a=commit;h=e0baba467c79213c691ba7e6494c3dcf504267f2

Author: Michael Tremer <michael.tremer@ipfire.org>

database: Migrate to psycopg3

Fixes: #12953
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>