I am trying to connect to postgres using python (postgres in Docker):
import psycopg2
DB_CONFIG = {
'dbname': 'transport',
'user': 'myuser',
'password': 'mypassword',
'host': 'my_postgres',
'port': '5432',
'client_encoding': 'UTF8',
'options' : '-c client_encoding=UTF8'
}
def con():
try:
return psycopg2.connect(**DB_CONFIG)
except Exception as e:
print(f"Error connecting to database: {e}")
print(con())
but I get the error:
Error connecting to database: 'utf-8' codec can't decode byte 0xdd in position 56: invalid continuation byte
How to fix it?
1