I'm new on Postgresql, and here I'm trying to make a connection between Python3 and Postgresql. Now I'm trying to create a new database on post 8888 on localhost. Here's my code from Python 3, and also when I try to debug this code, I do get a error, but I think that's because I didn't launch any server, on Postgresql. On the other side, I can't create a database on SQL, the server does say :
Server doesn't listen The server doesn't accept connections: the connection library reports could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 8888?
import psycopg2
#Connect to db
con = psycopg2.connect(
host = "localhost",
database = "Vartotojai",
user = "postgres",
password = "postgres"
)
cur = con.cursor()
# execute
cur.execute("select id, name from useriai")
rows = cur.fetchall()
for r in rows:
print(f"id {r[0]} name {r[1]}")
cur.close()
# Close connection
con.close()
Exception has occurred: psycopg2.OperationalError FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres"