Skip to content

Support psycopg3 - #208

Merged
Photonios merged 6 commits into
SectorLabs:masterfrom
snuderl:psycopg3
Apr 6, 2023
Merged

Photonios merged 6 commits into
SectorLabs:masterfrom
snuderl:psycopg3

Conversation

@snuderl

@snuderl snuderl commented Apr 5, 2023 •

Copy link
Copy Markdown
Contributor

Very minor changes needed to support this.

I am not sure what the best way to add tests for this would be, as ideally test would ran against both psycopg2 and psycopg3.

Edit:
Set up the tests.

P.S.
Really sweet testing setup.

@Photonios

Copy link
Copy Markdown
Contributor

I am not sure what the best way to add tests for this would be, as ideally test would ran against both psycopg2 and psycopg3.

This could be fixed by adding a new dimension to the Tox configuration file which already runs the tests against multiple Django and Python versions. See: https://github.com/SectorLabs/django-postgres-extra/blob/master/tox.ini

@Photonios Photonios left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread psqlextra/compiler.py
{
column.name: row[column_index]
for column_index, column in enumerate(cursor.description)
for column_index, column in enumerate(description)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change. How is aliasing it on line 190 changing how this works?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the with cursor now cleans up the data on the cursor on exit. So cusror.description ends up being None. So we just need to read it before the with block exits

@snuderl
snuderl force-pushed the psycopg3 branch 4 times, most recently from f829c93 to 118bf09 Compare April 6, 2023 06:49
@snuderl
snuderl requested a review from Photonios April 6, 2023 06:56
Comment thread .circleci/config.yml Resolved
damjankuznar
damjankuznar previously approved these changes Apr 6, 2023

@damjankuznar damjankuznar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread .circleci/config.yml Outdated

- run:
name: Run tests psycopg3
command: tox -e 'py<< parameters.pyversion >>-dj{<< parameters.djversions >>}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this install psycopg3? I don't see any references in tox.ini to psycopg3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, this was me trying to figure tox/circle out

Right now the djversion=42 uses psycopg3 (though It means that it does not test psycopg2)

Comment thread tox.ini
dj32: Django~=3.2.0
dj40: Django~=4.0.0
dj41: Django~=4.1.0
dj42: .[psycopg3]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the tests don't run against psycopg2 anymore. I will patch this up after merging this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#209

I just added this. Tests run against psycopg 2.8, 2.9 and 3.0 now with all supported Django versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Photonios
Photonios merged commit b428fda into SectorLabs:master Apr 6, 2023
@Photonios

Copy link
Copy Markdown
Contributor

@snuderl You can try it out in v2.0.9rc2

@snuderl

snuderl commented Apr 7, 2023

Copy link
Copy Markdown
Contributor Author

@snuderl You can try it out in v2.0.9rc2

Yup. Works with our codebase!

@adamantike

Copy link
Copy Markdown

I was also experiencing this issue, and bumping to one of the current RC releases fixed it. Looking for a new release to unpin our dependency from RC! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants