django-daiquiri / daiquiri

A framework for the publication of scientific databases
https://escience.aip.de/daiquiri
Apache License 2.0
26 stars 8 forks source link

UPDATE: update from psycopg2 to psycopg3 #239

Closed kimakan closed 3 months ago

kimakan commented 6 months ago

In the release notes for Django 4.2 it's mentioned that psycopg2 will be at some point deprecated in the future versions. We should think about moving to psycopg3. Differences to psycopg2.

kimakan commented 4 months ago

After some testing it seems that only the following method was incompatible with psycopg3 https://github.com/django-daiquiri/daiquiri/blob/5ae2a14f68bfab0b0d6c261ebce3e6359d6594de/daiquiri/core/adapter/database/postgres.py#L99-L102

It should be changed to

    def fetch_pid(self):
        return self.connection().connection.info.backend_pid

For now, it feels a bit suspicious that the psycopg update requires only such a tiny fix in daiquiri.

jochenklar commented 4 months ago

I think, from Django or postgres point of view, it is super weird that a web application needs the pid of the query process. I think we need it to abort the query, right? This is not what people usually do.

kimakan commented 4 months ago

Yes, the PID is used to abort to query https://github.com/django-daiquiri/daiquiri/blob/5ae2a14f68bfab0b0d6c261ebce3e6359d6594de/daiquiri/core/adapter/database/postgres.py#L148-L152

@jochenklar Do you think that query should be aborted in a different way?

jochenklar commented 4 months ago

No, I am hoping that this feature will not be removed altogether 😄