ARTICLE AD BOX
C:\inetpub\wwwroot\proyecto_transporte>python conexion.py Unexpected error: 'utf-8' codec can't decode byte 0xed in position 79: invalid continuation byte
I already tried saving the file as ANSI, verified that it is saved as UTF-8, and nothing seems to work. I don't know what else to try. If anyone has had a similar issue, I would really appreciate your help.
Here is the content of my script:
import psycopg2
def verificar_conexion(): try: conexion = psycopg2.connect( host="10.240.0.96", database="transporte_dev", user="postgres", password="***********", port="5432" )
print("Conexion exitosa a PostgreSQL") cursor = conexion.cursor() cursor.execute("SELECT version();") version = cursor.fetchone() print(f"Version de PostgreSQL: {version[0]}") cursor.close() conexion.close() print("Conexion cerrada correctamente") return True except psycopg2.OperationalError as e: print(f"Error de conexion: {e}") return False except Exception as e: print(f"Error inesperado: {e}") return Falseif name == "main": verificar_conexion()
