1

file .evn

DB_HOST=127.0.0.1:3307
DB_DATABASE=bookinghotel_db
DB_USERNAME=root
DB_PASSWORD=

file config.py

import os

basedir = os.path.abspath(os.path.dirname(__file__))

class Config(object):
    HOST = str(os.environ.get("DB_HOST"))
    DATABASE = str(os.environ.get("DB_DATABASE"))
    USERNAME = str(os.environ.get("DB_USERNAME"))
    PASSWORD = str(os.environ.get("DB_PASSWORD"))

    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://' + USERNAME + '/' + PASSWORD + '@' + HOST + '/' + DATABASE
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_RECORD_QUERIES = True`
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'root' ([Errno 11001] getaddrinfo failed)")
1
  • Welcome to Stack Overflow. Please check the syntax of your SQLALCHEMY_DATABASE_URI. It doesn't look right. between username and password, I don't believe it is a /. Commented Sep 25, 2023 at 3:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.