Use psycopg3 if psycopg2 is not installed.

Fixes #3036
This commit is contained in:
Charles Leifer
2026-03-26 17:33:26 -05:00
parent 007fd50bc7
commit 89f3031dac
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -21,6 +21,7 @@ https://github.com/coleifer/peewee/releases
* Better handling of duplicated column names in cursor wrapper implementations.
* Improve performance of ModelCursorWrapper when reconstructing model instance
graphs after multi-table selects.
* If only psycopg3 is installed, use it by default (#3036)
[View commits](https://github.com/coleifer/peewee/compare/4.0.2...master)
+1 -1
View File
@@ -4138,7 +4138,7 @@ class PostgresqlDatabase(Database):
self._encoding = encoding
prefer_psycopg3 = kwargs.pop('prefer_psycopg3', False)
if psycopg is not None and prefer_psycopg3:
if psycopg is not None and (prefer_psycopg3 or psycopg2 is None):
self._adapter = self.psycopg3_adapter()
else:
self._adapter = self.psycopg2_adapter()