django-postgres-copy icon indicating copy to clipboard operation
django-postgres-copy copied to clipboard

support psycopg3

Open davidszotten opened this issue 6 months ago • 9 comments

this is a bit fiddly because all the supported use-cases but all the tests pass locally with either psycopg version

davidszotten avatar Jun 16 '25 20:06 davidszotten

Thanks for the stab. Is there a way to wrap that compat into something a little more elegant than a big try and except? I'm not an expert on Python backwards compatibility, but I wonder if there's a common pattern from a big library like Django that we can borrow from. (Maybe something our friend Claude would know?)

palewire avatar Jun 16 '25 20:06 palewire

Thanks for the stab. Is there a way to wrap that compat into something a little more elegant than a big try and except? I'm not an expert on Python backwards compatibility, but I wonder if there's a common pattern from a big library like Django that we can borrow from. (Maybe something our friend Claude would know?)

i followed django https://github.com/django/django/blob/d6e0c710173531645bd3689bc03e9b809aa3d220/django/db/backends/postgresql/psycopg_any.py#L4

davidszotten avatar Jun 16 '25 20:06 davidszotten

i followed django

TIL! ;)

I'm going to blitz through the repo with a machete and update a bunch of other stale stuff while I'm at it here.

palewire avatar Jun 16 '25 20:06 palewire

Like the versions we're testing and such.

palewire avatar Jun 16 '25 20:06 palewire

Like the versions we're testing and such.

that would be helpful, thanks. see my latest error with distutils on py 3.12.

davidszotten avatar Jun 16 '25 21:06 davidszotten

maybe we should switch away from setup.py test (see eg https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#python-setup-py-test ) and use eg pytest? happy to make a pr for this tomorrow

davidszotten avatar Jun 16 '25 21:06 davidszotten

maybe we should switch away from setup.py test (see eg https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#python-setup-py-test ) and use eg pytest? happy to make a pr for this tomorrow

I'd be up for this in a separate PR. The main trick is working in those different Django settings tricks. My standard approach for new libraries changed to uv and pyproject.toml a while ago (as seen here). I've been trying to avoid opening that can of worms thus far, but maybe we should.

palewire avatar Jun 16 '25 21:06 palewire

Looks like I got tests passing, even with 3.13. That's good progress.

palewire avatar Jun 16 '25 21:06 palewire

@thorntonedgar and @wlorenzetti, do you have any comments or concerns about this implementation?

palewire avatar Jun 16 '25 21:06 palewire

I'm going to merge this in a few minutes, but before I do I'm going to experiment with asking Claude to drum up some additional unit tests. Mostly as an experiment for me. I'm not optimistic on how well it will do based on some early local tomfoolery.

palewire avatar Jun 22 '25 18:06 palewire

How come you want dedicated tests for the compt module? It is already tested by running the rest of the suite with each psycopg version

davidszotten avatar Jun 22 '25 18:06 davidszotten

I'm good with what you've got. It's strictly an experiment to see what AI comes up with. I'm just curious. I haven't got to play too much with these tools. I apologize for the indulgence.

palewire avatar Jun 22 '25 18:06 palewire

Alrighty. I'm good to merge this. I'm going to hammer in a couple long overdue modernizations before I ship a new version like uv for env management and some mypy static type hinting. I expect to get it shipped today. Thank you very much for this excellent pull request and I'll flag you when I get it out on pypi.

palewire avatar Jun 22 '25 18:06 palewire

Version 2.8.0 is released. Please give it a shot and let me know if you have any troubles.

https://pypi.org/project/django-postgres-copy/#history

palewire avatar Jun 22 '25 20:06 palewire