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,