-
Notifications
You must be signed in to change notification settings - Fork 48
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
interest in support for in-memory data? #25
Comments
Maybe! Just to make sure I understand, the idea is to insert data into an existing table managed by a Django model? |
Yep, the way I have it working is that you instantiate a bunch of objects of the model type. It'd look something like:
& internally it'd essentially create a temporary CSV file w/ all of the data then load it via the same COPY mechanism. |
Let's do it! On Fri, Jul 8, 2016, 9:17 PM James Turk [email protected] wrote:
|
Is there any progress? |
I thought about this when I first came across this project a few weeks ago. If I remember correctly, the in-memory object would need a read() and readlines() method based on psycopg2's copy_expert() method (see: https://github.com/psycopg/psycopg2/blob/6da3e7ee69971cd6cb692765a4d66a5ce405f104/psycopg/cursor_type.c#L1366) |
I never got a chance to come back & contribute what I had, but here it is as a POC, in case someone else wants to pick this up.
|
Thanks for sharing your work, @jamesturk. If anybody wants to take a run at a pull request it would be greatly appreciated. |
I think it's only partial progress towards the goal here, but I just merged #68, which adds support for submitting file objects in addition to file paths. |
I wanted to check if a patch to support something like:
CopyMapping(model=Entry, data=huge_list_of_unsaved_entries)
would be a welcome patchI have some code I was considering making into a library that uses pg COPY to replace Django's bulk_create in the form of a function w/ the signature:
I was considering abstracting this into a generic library to use Postgres' COPY TO/FROM when I found this library & figured I'd check if you'd be open to expanding the scope for this use case.
The text was updated successfully, but these errors were encountered: