sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at127.0.0.1, port 5432 failed:FATAL:password authentication failed

Viewed 46

I am trying to create a database for my line bot but there are some problem connect to database

here is my question

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "127.0.0.1", port 5432 failed: FATAL:  password authentication failed for user "admin"

and I triple check my owner name and password they are same!!

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://admin:er******10@127.0.0.1:5432/userid'
db = SQLAlchemy(app)

@app.route('/')
def index():
    sql = """
    CREATE TABLE formuser (
    id serial NOT NULL,
    uid character varying(50) NOT NULL,
    PRIMARY KEY (id));

    CREATE TABLE hoteluser (
    id serial NOT NULL,
    uid character varying(50) NOT NULL,
    PRIMARY KEY (id));

    CREATE TABLE booking (
    id serial NOT NULL,
    bid character varying(50) NOT NULL,
    roomtype character varying(20) NOT NULL,
    roomamount character varying(5) NOT NULL,
    datein character varying(20) NOT NULL,
    dateout character varying(20) NOT NULL,
    PRIMARY KEY (id));
    """
    db.engine.execute(sql)
    return "succ"

if __name__ == '__main__':
   app.run(debug=True)

I still cant connect my database

1 Answers

Are you sure that your username is admin ? Just read the error lmao. Or try it out with postgresql://admin:er******10@localhost:5432/userid If this doesn't work, try to change your localhost in the folder local.ini Change it to 0.0.0.0

Related