import psycopg2
from config import host, user, password, db_name, port
connection = None
try:
# подключаемся к базе
connection = psycopg2.connect(
host=host,
user=user,
password=password,
database=db_name,
port=port
)
connection.autocommit = True
# cursor нужен чтобы взаимодействовать с БД
# сейчас создаем нашу БД
with connection.cursor() as cursor:
cursor.execute(
"""CREATE TABLE IF NOT EXISTS data1 (
price int NOT NULL,
styles text NOT NULL,
runes text);"""
)
except Exception as _ex:
print("[INFO] Error while working with PostgreSQL", _ex)
finally:
if connection:
connection.close()
print("[INFO] PostgreSQL connection closed")
config
host = "127.0.0.1"
user = "postgres"
password = "14101999"
db_name = "data"
port = "5432"
When executing , it outputs [INFO] Error while working with PostgreSQL
I do not understand at all what the problem is and why the database is not being created, I seem to have indicated everything correctly in config...
_exportion of the exception message.