Psycopg2: copy_from() doesn't support HEADER

Created on 9 Apr 2015  路  6Comments  路  Source: psycopg/psycopg2

seems like copy_from() doesn't support "header", forcing you to use copy_expert.

seems like this should be an easy add...

All 6 comments

IMO we shouldn't: these functions are already a christmas tree and new parameters are added at every version. 9.4's COPY FROM has 12.

copy_expert is there for this reason.

I highly wish you guys would reconsider this. It might be a christmas tree, but this is a very simple feature which is very often needed, and completely disables the usage of the function for some people. It's one keyword argument, complex functions need many arguments.

@Mahi not only we won't, but in some future psycopg version we will drop copy_from() and copy_to() altogether. We will rename copy_expert() into copy() though, so we will save everyone some typing. We will also paint the function in a friendly shade of green.

is copy_from() just a wrapper for copy_expert()? I'm having a particular issue which is that when copying to AWS RDS, you need to be a superuser to copy using copy_expert() or cur.execute(), but you are not allowed superuser access on rds instances.

I don't seem to have this error with copy_from() but the header thing does mess things up for me.
Hence if the methodology is actually different then it would be beneficial to add the options to the copy_from() method.

@rshap91 It is exactly the same code path. copy_from() creates a string from arguments, copy_expert() just passes through the user input.

ahh oh well.

Was this page helpful?
0 / 5 - 0 ratings