django-daiquiri/daiquiri

UPDATE: update from psycopg2 to psycopg3

Closed this issue · 4 comments

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.

After some testing it seems that only the following method was incompatible with psycopg3

def fetch_pid(self):
return self.connection().connection.get_backend_pid()

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.

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.

Yes, the PID is used to abort to query

def abort_query(self, pid):
sql = 'select pg_cancel_backend(%(pid)i)' % {'pid': pid}
self.execute(sql)

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

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