Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psycopg3 #42

Open
petrprikryl opened this issue Mar 12, 2024 · 4 comments
Open

psycopg3 #42

petrprikryl opened this issue Mar 12, 2024 · 4 comments

Comments

@petrprikryl
Copy link

Hi, are there any plans supporting new psycopg version https://pypi.org/project/psycopg/?

@altaurog
Copy link
Owner

Hi @petrprikryl , thanks for your interest. TBH I have not made time to explore the new version at all, but I had the impression from the announcements in the psycopg mailing list that it does binary copy using native functionality. Is there still a use for pgcopy with psycopg3?

@petrprikryl
Copy link
Author

I think that if you want use binary mode, you still need to handle the data types manually. So there is still room for pgcopy to shine and handle it automatically like it does with psycopg2.

https://www.psycopg.org/articles/2020/11/15/psycopg3-copy/

... which might be more efficient than the textual format, but requires more care with the data types, as the server will not even perform an innocent int4 -> int8 cast for you

https://www.psycopg.org/psycopg3/docs/basic/copy.html#binary-copy

@altaurog
Copy link
Owner

The documentation is rather sparse. It seems clear that the interface is different, and that some data types are handled. Have you experimented with it? Can you give an example of what does and what doesn’t work? How do you imagine pgcopy would work with psycopg3? Would the pgcopy interface remain the same or would it somehow augment the new copy interface of psycopg3, presumably by automating a call to set_types()?
How would you suggest managing psycopg dependencies? Would this be a distinct pypi package? A different pgcopy version? Or a single library with distinct modules for distinct psycopg versions?

@altaurog
Copy link
Owner

The ability to send data directly without having to write to a file object looks nice

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

No branches or pull requests

2 participants