The author of Psycopg3 himself has already created some demonstration
branches with the integration test of Django and Psycopg3.
https://www.psycopg.org/articles/2021/08/02/psycopg3-django-driver/
I propose to add a new database backend for PostgreSQL based on Psycopg3
in parallel with the one based on Psycopg2, we can start from the work
already done.
https://github.com/dvarrazzo/django-psycopg3-backend
P.S. In the past I believe there was a similar situation when Psycpg2
support was added in parallel with version 1.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Daniele Varrazzo):
Hello Paolo, thank you for looking into this.
Happy to give you my support, with explanations and eventual changes on
the Psycopg side if needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:1>
Comment (by Paolo Melchiorre):
Hi Daniele, I think the first step for you can be to rebase your Django
fork [1] with the official Django [2] repository and then open a PR from
your `psycopg3-support` branch to the Django `main` branch.
[1] https://github.com/dvarrazzo/django/tree/psycopg3-support
[2] https://github.com/django/django
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:2>
* cc: Daniele Varrazzo (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:3>
* stage: Unreviewed => Accepted
Comment:
Adding support for psycopg3 seems relevant since it has a stable release,
so I'm tagging it as accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:4>
Comment (by Daniele Varrazzo):
Hello Paolo,
I have rebased my Django branch on current main in a new
[https://github.com/dvarrazzo/django/tree/psycopg3-4.1 psycopg3-4.1
branch] and I have made the [https://github.com/dvarrazzo/django-
psycopg3-backend django-psycopg3-backend] ''almost'' compatible with it:
there are a few issues described [https://github.com/dvarrazzo/django-
psycopg3-backend/commit/17cd24ae8eb49025b2a859c19a2a30081c2a028b in this
commit message], together with how to run tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:5>
Comment (by Paolo Melchiorre):
Hi Daniele
Thank, I'll take a look at both branches and let you know.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:6>
* cc: אורי (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:7>
* cc: Adam Johnson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:8>
* cc: Michael P. Jung (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:9>
* cc: Saeed Blanchette (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:10>
* cc: Florian Apolloner (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:11>
* cc: Adam Wróbel (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:12>
* cc: Andreas Rammhold (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:13>
* cc: Alexander Nestorov (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:14>
* cc: Ben Plessinger (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:15>
* cc: Thiago Bellini Ribeiro (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:16>
* cc: Mika (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:17>
* cc: Anvesh Mishra (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:18>
* cc: Maciej Olko (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:19>
Comment (by Florian Apolloner):
Given the CCs on this ticket I'd highly appreciate review and tests of the
PR in https://github.com/django/django/pull/15687 -- remember the more
reviews and tests we get the sooner this will get in :)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:20>
* cc: Ülgen Sarıkavak (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:21>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"04518e310d4552ff7595a34f5a7f93487d78a406" 04518e31]:
{{{
#!CommitTicketReference repository=""
revision="04518e310d4552ff7595a34f5a7f93487d78a406"
Refs #33308 -- Enabled explicit GROUP BY and ORDER BY aliases.
This ensures explicit grouping from using values() before annotating an
aggregate function groups by selected aliases if supported.
The GROUP BY feature is disabled on Oracle because it doesn't support it.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:22>
* owner: nobody => Florian Apolloner
* status: new => assigned
Comment:
Assign to @apollo13 because he's working on this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:23>
Comment (by GitHub <noreply@…>):
In [changeset:"7990d254b0af158baf827fafbd90fe8e890f23bd" 7990d25]:
{{{
#!CommitTicketReference repository=""
revision="7990d254b0af158baf827fafbd90fe8e890f23bd"
Refs #33308 -- Improved adapting DecimalField values to decimal.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:24>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d87a7b9f4b4c75fc03ce6bbf55c880a79d524306" d87a7b9]:
{{{
#!CommitTicketReference repository=""
revision="d87a7b9f4b4c75fc03ce6bbf55c880a79d524306"
Refs #33308 -- Stopped inheriting from FieldGetDbPrepValueMixin by
PostgresOperatorLookup.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:25>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"5c23d9f0c32f166c81ecb6f3f01d5077a6084318" 5c23d9f]:
{{{
#!CommitTicketReference repository=""
revision="5c23d9f0c32f166c81ecb6f3f01d5077a6084318"
Refs #33308 -- Used get_db_prep_value() to adapt JSONFields.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:26>
* cc: Sage Abdullah (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:27>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"3cafb783f3f711c7413ba2b8d7c8ff750bd4d6e1" 3cafb783]:
{{{
#!CommitTicketReference repository=""
revision="3cafb783f3f711c7413ba2b8d7c8ff750bd4d6e1"
Refs #33308 -- Used psycopg's errors instead of errorcodes.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:28>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"149b55fefad03c18589d580ef53d41e7c99408ed" 149b55f]:
{{{
#!CommitTicketReference repository=""
revision="149b55fefad03c18589d580ef53d41e7c99408ed"
Refs #33308 -- Ensured type handlers are registered for all PostgreSQL
specific tests.
Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:29>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d3e746ace5eeea07216da97d9c3801f2fdc43223" d3e746ac]:
{{{
#!CommitTicketReference repository=""
revision="d3e746ace5eeea07216da97d9c3801f2fdc43223"
Refs #33308 -- Added get_type_oids() hook and simplified registering type
handlers on PostgreSQL.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:30>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"0ff46591ac3010841c73fd26e0fef93995fedd99" 0ff4659]:
{{{
#!CommitTicketReference repository=""
revision="0ff46591ac3010841c73fd26e0fef93995fedd99"
Refs #33308 -- Deprecated support for passing encoded JSON string literals
to JSONField & co.
JSON should be provided as literal Python objects an not in their
encoded string literal forms.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:31>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"2fecf99ade208e3a80958ee4fc28ff62549c575b" 2fecf99]:
{{{
#!CommitTicketReference repository=""
revision="2fecf99ade208e3a80958ee4fc28ff62549c575b"
Refs #33308 -- Made PostGISAdapter do not use psycopg2's Binary().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:32>
* cc: אורי (removed)
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:33>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"3e3b7f691b5cc41c357966ce3f91a8d13c6c1d4d" 3e3b7f6]:
{{{
#!CommitTicketReference repository=""
revision="3e3b7f691b5cc41c357966ce3f91a8d13c6c1d4d"
Refs #33308 -- Avoided passing None to RawSQL's params.
Passing None to params causes errors in determining the data type on
psycopg3.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:34>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"6a2165816394ab4bb259f6171e82417e098e97a6" 6a216581]:
{{{
#!CommitTicketReference repository=""
revision="6a2165816394ab4bb259f6171e82417e098e97a6"
Refs #33308 -- Modernized database wrapper in the PostgreSQL backend.
- Used connection.info instead of connection.get_parameter_status() and
connection.server_info which don't exist in psycopg 3.
- Set encoding using the client_encoding connection parameter instead
of connection.set_client_encoding() that doesn't exist in psycopg 3.
- Used the dbname connection parameter instead of deprecated
alias - database.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:35>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"2ebfbd894e21e1656c1e1f32d98b8df7a32d3649" 2ebfbd89]:
{{{
#!CommitTicketReference repository=""
revision="2ebfbd894e21e1656c1e1f32d98b8df7a32d3649"
Refs #33308 -- Moved psycopg2 imports to the psycopg_any module.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:36>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"2f38f7b8f9bd65905dc6bec4f3e2a30b5da8e338" 2f38f7b]:
{{{
#!CommitTicketReference repository=""
revision="2f38f7b8f9bd65905dc6bec4f3e2a30b5da8e338"
Refs #33308 -- Added psycopg_any.sql.quote() hook.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:37>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"1d90c9b1132482d446ca8375c151e894002c9e8d" 1d90c9b]:
{{{
#!CommitTicketReference repository=""
revision="1d90c9b1132482d446ca8375c151e894002c9e8d"
Refs #33308 -- Added psycopg_any.IsolationLevel.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:38>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"db7bb3b64e469fbb5c79e7b5b2fcb890434aa60f" db7bb3b6]:
{{{
#!CommitTicketReference repository=""
revision="db7bb3b64e469fbb5c79e7b5b2fcb890434aa60f"
Refs #33308 -- Added DatabaseOperations.compose_sql() on PostgreSQL.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:39>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
Comment:
[https://github.com/django/django/pull/15687 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:40>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca" 09ffc5c]:
{{{
#!CommitTicketReference repository=""
revision="09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca"
Fixed #33308 -- Added support for psycopg version 3.
Thanks Simon Charette, Tim Graham, and Adam Johnson for reviews.
Co-authored-by: Florian Apolloner <flo...@apolloner.eu>
Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:41>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"a6511bc23329f1d3939571ad01d3176f8f6cb786" a6511bc]:
{{{
#!CommitTicketReference repository=""
revision="a6511bc23329f1d3939571ad01d3176f8f6cb786"
Refs #33308 -- Added tests for queryset ordered by annotation with
nulls_first/nulls_last.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:42>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"312d0f88b4ba47278f53f37ee2735309eda3e913" 312d0f88]:
{{{
#!CommitTicketReference repository=""
revision="312d0f88b4ba47278f53f37ee2735309eda3e913"
[4.2.x] Refs #33308 -- Added tests for queryset ordered by annotation with
nulls_first/nulls_last.
Backport of a6511bc23329f1d3939571ad01d3176f8f6cb786 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:43>
Comment (by GitHub <noreply@…>):
In [changeset:"0c1518ee429b01c145cf5b34eab01b0b92f8c246" 0c1518e]:
{{{
#!CommitTicketReference repository=""
revision="0c1518ee429b01c145cf5b34eab01b0b92f8c246"
Fixed #34590 -- Reverted "Refs #33308 -- Improved adapting DecimalField
values to decimal."
This reverts 7990d254b0af158baf827fafbd90fe8e890f23bd.
Thanks Marc Odermatt for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:44>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"91f8df5c2e711ff4b3d10602181d8a6daa62a93a" 91f8df5c]:
{{{
#!CommitTicketReference repository=""
revision="91f8df5c2e711ff4b3d10602181d8a6daa62a93a"
[4.2.x] Fixed #34590 -- Reverted "Refs #33308 -- Improved adapting
DecimalField values to decimal."
This reverts 7990d254b0af158baf827fafbd90fe8e890f23bd.
Thanks Marc Odermatt for the report.
Backport of 0c1518ee429b01c145cf5b34eab01b0b92f8c246 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:45>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"5e4c1793b714a975400b9277a66f99efafa2d92c" 5e4c179]:
{{{
#!CommitTicketReference repository=""
revision="5e4c1793b714a975400b9277a66f99efafa2d92c"
Refs #33308 -- Removed support for passing encoded JSON string literals to
JSONField & co.
Per deprecation timeline.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33308#comment:46>