Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mASrN-0003Er-Vm for psycopg@arkaria.postgresql.org; Mon, 02 Aug 2021 07:59:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mASrL-0000cY-VG for psycopg@arkaria.postgresql.org; Mon, 02 Aug 2021 07:59:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mASrL-0000cQ-Nq for psycopg@lists.postgresql.org; Mon, 02 Aug 2021 07:59:39 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mASrF-0005MT-Kn for psycopg@postgresql.org; Mon, 02 Aug 2021 07:59:39 +0000 Received: by mail-lj1-x230.google.com with SMTP id b21so22747042ljo.13 for ; Mon, 02 Aug 2021 00:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=fDa6dwPd6gNw6tQHlCgInaKdI6Lkm+h6Q92nCPKq9ro=; b=DkpHvl/d1ZO6HW4nxMsLJiV+x9HOwmxGn/o4d/9YZ3szxWQRZQx4kZuHsgoBH04R+f Fhk2vHVsnZBP3UarN93k1r4FpKOpL98R/prz9J5gerutXaf5cQqq36sZA91DVbozSZbi ZRjftM+qtA7DZG8kMLbw3lAPX9aE9CbjQbnfHcYCRbC6Zm+dPCLXXh6MyuBohsg5DjVK tBY4qnQGV+wUgXOO/kaUsMTNqvgrszLtZx+Uz1tvcfj/2HT3nvTa9Cw0eI5VDb1U7n4Q RNIDtHmlmU5Yd7yQd+PHtJ+4QiIev+GnU2MiLPNflJLCmp1DKrLOgS8Lrp4GXLHU+6Xm VjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=fDa6dwPd6gNw6tQHlCgInaKdI6Lkm+h6Q92nCPKq9ro=; b=SM1qRuR0cV2Tdpc3ACswZ3AUgnjIUcnHmW/NTIPvgsXJ9i6PfwCdXrjo4e/OCWsUn1 RTzzmJP6ZyKLBz96ptEaasymQ0mVQITy0ZPlHeYciD6W2s1eDNzpoZ5p+RofMDpl0PU6 jhr4kR6Im5cQ+cruxjS67mt01YxeDwseBtFBA6r7i0UFjDvD8P9PpxjqujrOdbP1+vA9 z1DlXHuVUu2xdrJReK9+fHTZmURZl/wul9f8VCazGqXVFpjFryrNzpVcqcO7S+lArTfe ddgDaA5mZt5hnRSozlf1F9+CtEDriRz2q7IuRV69QpbdJatggY17sTJvBibTEmepOVV2 yjOg== X-Gm-Message-State: AOAM533HcGvf2I1E5irbULbkgwoCGkhSXR1WqOnH65Xzswo0XJ/2JYti 8yX3M+5dIT/gWlu2yp71dbz4mjGyoo6wRahH+fRmtINvTcIVZyF0 X-Google-Smtp-Source: ABdhPJy1Q633B1I3Cef/FrIGa3vD4Hc5dtIQQYF/9V6qu7QgB8v0z0NkM4HrXV4pnmz/7yBFjxs/ljagCxcbuz3jo0E= X-Received: by 2002:a2e:a54d:: with SMTP id e13mr10714347ljn.1.1627891172324; Mon, 02 Aug 2021 00:59:32 -0700 (PDT) MIME-Version: 1.0 From: Daniele Varrazzo Date: Mon, 2 Aug 2021 09:59:19 +0200 Message-ID: Subject: A Django backend for PostgreSQL using Psycopg 3 To: psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I have implemented a backend to enable Django to use PostgreSQL using Psycopg 3. The backend is currently implemented as an external module [1] requiring a few modifications to Django [2] to successfully run the whole Django test suite. Most of the changes are import-related (breaking the assumption that "psycopg2" is always present if you are talking to PostgreSQL); a few changes are more interesting, because they show the difference in the database behaviour moving from client-side to server-side parameters passing. I have written an article explaining the changes needed [3] which you might find useful. [1] https://github.com/dvarrazzo/django-psycopg3-backend [2] https://github.com/django/django/compare/stable/3.2.x...dvarrazzo:psycopg3-support [3] https://www.psycopg.org/articles/2021/08/02/psycopg3-django-driver/ The next step, on this front, will be to liaise with the Django project and understand if there is interest in accepting the changes (I hope so) and whether the changes need to be adapted to better suit the Django project. On the Psycopg 3 front, I would say that supporting the whole Django test suite is a good maturity test of which I am very happy. I am completing a final review looking for missing bits (verifying that the tests in the psycopg2 test suite have an equivalent in Psycopg 3), after which we can release a package with hopefully the definitive adapter interface. Thank you very much for your support. I hope that this work will be useful for everyone. -- Daniele