Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I did this in my python code, based on the documentation here and it's mention here

# anything can be used as a file if it has .read() and .readline() methods
data = StringIO.StringIO()
data.write('\n'.join(['Tom\tJenkins\t37',
                  'Madonna\t\N\t45',
                  'Federico\tDi Gregorio\t\N']))
data.seek(0)

curs.copy_from(data, 'distributors')

I got this error: Traceback (most recent call last): File "", line 1, in cursor.copy_from(data, 'distributors') InternalError: current transaction is aborted, commands ignored until end of transaction block

share|improve this question

1 Answer 1

Found the answer here:

There was an attempted query run of an erroneous query using the same database connection. (For details: I had run a copy_from execution on this db connection with incorrect data. It had failed. And, then I modified my data to be in correct format)

When your previous query/command on the database using this connection had a problem/error, it needs to be rolled back using connection.rollback() call. Once, you execute that code, and re-run the fresh correct code, you would get data to be properly copied from Python code to Postgres database.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.