#๐Ÿ”’ My code can't make a connection with my database.

4 messages ยท Page 1 of 1 (latest)

late pond
#

I'm trying make a connection with my database, i see many videos trying to make a connection but te error still the same, if someone can help me.

code:
import psycopg2

def connect_to_db():
try:
conn = psycopg2.connect(
dbname="spotify",
user="postgres",
password="minhasenha",
host="localhost",
port="5432",
options="-c client_encoding=UTF8"
)
print("Connection successful")

except Exception as e:
    print(f"Error: {e}")

if name == "main":
connect_to_db()

error:
'utf-8' codec can't decode byte 0xe7 in position 78: invalid continuation byte'

everthing is on

OBS: If you can explain it in Portuguese I would be grateful

naive gateBOT
#

@late pond

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

naive gateBOT
#

@late pond

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.