Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

i'm trying to update some records in an old "PostgreSQL 8.3.19" database (server_encoding='UTF8'), and i get this error:

(psycopg2.DataError) invalid byte sequence for encoding "UTF8": 0x8d HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

This is my code:

engine = create_engine('postgresql://user:pass@host:port/dbname', client_encoding ='utf8')

new_local_path = {str} 'path'
row_source_file_id= {int} 'number'

try:
    update_query = text("""UPDATE local_table SET local_path='{}' where source_file_id={}""".format(new_local_path, str(row.source_file_id)))

    self.db.engine.execute(update_query)

except Exception as exception:
    print(exception)

when debugging, update_query={TextClause}, new_local_path={str}

I'm setting the client encoding on the engine by reading about similar errors, but can't figure how to solve it.

Very much appreciated,

share|improve this question
    
", comment reposted, the parameter binding thrown an error " still the same sort of comment that's not welcome here. Please always state the exact error. And also learn to google first with that error – e4c5 Jan 10 at 11:56

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.