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

Allow inserttable() to take columns as parameter #24

Closed
Cito opened this issue Feb 15, 2020 · 3 comments
Closed

Allow inserttable() to take columns as parameter #24

Cito opened this issue Feb 15, 2020 · 3 comments
Milestone

Comments

@Cito
Copy link
Member

Cito commented Feb 15, 2020

Suggested on the mailing list 2017-01:

The method Connection.inserttable(table, values) in the classic module might take more parameters, e.g. columns, similar to the Cursor.copy_from(...) method in the DB API 2 module.

(copied from Trac ticket 73, created 2018-04-23)

@Cito
Copy link
Member Author

Cito commented Feb 15, 2020

Actually I don't think a columns parameter would be much useful here and only tarnish the pleasant simplicity of this method. You can easily remove superfluous columns from the values argument in Python before passing it to the method. And the other copy_from parameters are not applicable here anyway.

(copied from Trac 2019-04-25)

@Cito
Copy link
Member Author

Cito commented Feb 15, 2020

Justin: I don't think we're talking about the same thing. The request was to allow inserting columns "a,c" into a table with columns "a,b,c,d" (we need to do this all the time). That's needed in case columns b,d have default values (otherwise NULL would work fine).

Doesn't this just need to accept an optional list of column names and join them with commas?
sprintf(buffer, "copy %s from stdin", table);
to allow:
COPY t(i) FROM stdin

I don't know for sure if we'd be able to use this for either of our loaders, but I suspect it would be competitive or better than prepared statements, for use cases where it can be applied.

(copied from Trac 2019-05-14)

@Cito Cito added this to the 5.1 milestone Feb 15, 2020
@Cito Cito modified the milestones: 5.1, 5.2 Jun 19, 2020
@Cito
Copy link
Member Author

Cito commented Jun 20, 2020

See discussion on the mailing list 2020-06-20, will be released in 5.2.

@Cito Cito closed this as completed Jun 20, 2020
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

1 participant