{{ message }}
feat(postgres): add copyfrom support#92
Open
kellen-miller wants to merge 5 commits into
Open
Conversation
643c37c to
908c96f
Compare
August 23, 2025 19:08
908c96f to
2ff13ad
Compare
August 23, 2025 19:13
There was a problem hiding this comment.
Pull request overview
This PR implements support for the :copyfrom command in sqlc-gen-python, enabling efficient bulk insert operations. The implementation leverages SQLAlchemy's executemany behavior by passing lists of parameter dictionaries to Connection.execute().
Key Changes:
- Added
:copyfromcommand support with automatic handling of both struct and non-struct parameters - Removed the previous error that blocked CopyFrom usage
- Added comprehensive test coverage and examples demonstrating both sync and async usage
Reviewed changes
Copilot reviewed 44 out of 45 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/gen.go | Core implementation: adds BuildCopyFromBody, addCopyFromArgs, and buildStructToDictList methods; removes CopyFrom error; adds switch cases for :copyfrom in sync/async queriers |
| internal/imports.go | Adds import logic for typing.List and typing.Any types needed by copyfrom methods |
| internal/endtoend/testdata/copyfrom/* | New end-to-end test case with schema, queries, and expected generated code covering multiple copyfrom scenarios |
| examples/src/authors/query.sql | Adds example CreateAuthorsBatch copyfrom query |
| examples/src/authors/query.py | Generated code demonstrating copyfrom method with List[Any] parameter |
| examples/src/tests/test_authors.py | Test cases validating both sync and async copyfrom functionality |
| README.md | Documentation explaining copyfrom usage with examples for both List[Any] and typed struct parameters |
| internal/endtoend/testdata/*/sqlc.yaml | Updated sha256 hashes for new WASM binary version |
| internal/endtoend/testdata//python/.py | Updated generated file version comments from v1.28.0 to v1.29.0 |
| .gitignore | Adds .idea/ IDE directory to gitignore |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Collaborator
|
Hey @kellen-miller - will try take a look at this soon. Feel free to ping me if you don't get a review in the next week or so! |
Sorry, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
Closes #63