Forums

Error running WSGI application / sqlalchemy.exc.InterfaceError: (MySQLdb._exceptions.InterfaceError) (0, '')

**I don't know what to do anymore.

When I use the console, I can verify that the database is working well.

When I run the app in localhost, it works well until opening a page that query something in the database.

When trying to deploy I get this:**

Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

ERROR LOG:

2023-06-17 00:44:21,624: Error running WSGI application 2023-06-17 00:44:21,629: sqlalchemy.exc.InterfaceError: (MySQLdb.exceptions.InterfaceError) (0, '') 2023-06-17 00:44:21,629: (Background on this error at: https://sqlalche.me/e/14/rvf5) 2023-06-17 00:44:21,629: File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2095, in __call__ 2023-06-17 00:44:21,629: return self.wsgi_app(environ, start_response) 2023-06-17 00:44:21,630: 2023-06-17 00:44:21,630: File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2088, in wsgi_app 2023-06-17 00:44:21,630: ctx.auto_pop(error) 2023-06-17 00:44:21,630: 2023-06-17 00:44:21,630: File "/usr/local/lib/python3.10/site-packages/flask/ctx.py", line 490, in auto_pop 2023-06-17 00:44:21,631: self.pop(exc) 2023-06-17 00:44:21,631: 2023-06-17 00:44:21,631: File "/usr/local/lib/python3.10/site-packages/flask/ctx.py", line 477, in pop 2023-06-17 00:44:21,631: app_ctx.pop(exc) 2023-06-17 00:44:21,632: 2023-06-17 00:44:21,632: File "/usr/local/lib/python3.10/site-packages/flask/ctx.py", line 259, in pop 2023-06-17 00:44:21,632: self.app.do_teardown_appcontext(exc) 2023-06-17 00:44:21,633: 2023-06-17 00:44:21,633: File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1950, in do_teardown_appcontext 2023-06-17 00:44:21,633: self.ensure_sync(func)(exc) 2023-06-17 00:44:21,633: 2023-06-17 00:44:21,633: File "/usr/local/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 899, in shutdown_session 2023-06-17 00:44:21,634: self.session.remove() 2023-06-17 00:44:21,634: 2023-06-17 00:44:21,634: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/scoping.py", line 181, in remove 2023-06-17 00:44:21,634: self.registry().close() 2023-06-17 00:44:21,634: 2023-06-17 00:44:21,634: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1793, in close 2023-06-17 00:44:21,635: self._close_impl(invalidate=False) 2023-06-17 00:44:21,635: 2023-06-17 00:44:21,635: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1835, in _close_impl 2023-06-17 00:44:21,635: transaction.close(invalidate) 2023-06-17 00:44:21,635: 2023-06-17 00:44:21,636: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 923, in close 2023-06-17 00:44:21,636: transaction.close() 2023-06-17 00:44:21,637: 2023-06-17 00:44:21,637: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2335, in close 2023-06-17 00:44:21,637: self._do_close() 2023-06-17 00:44:21,637: 2023-06-17 00:44:21,638: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2558, in _do_close 2023-06-17 00:44:21,638: self._close_impl() 2023-06-17 00:44:21,638: 2023-06-17 00:44:21,638: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2544, in _close_impl 2023-06-17 00:44:21,639: self._connection_rollback_impl() 2023-06-17 00:44:21,639: 2023-06-17 00:44:21,639: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2536, in _connection_rollback_impl 2023-06-17 00:44:21,639: self.connection._rollback_impl() 2023-06-17 00:44:21,639: 2023-06-17 00:44:21,639: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 985, in _rollback_impl 2023-06-17 00:44:21,639: self._handle_dbapi_exception(e, None, None, None, None) 2023-06-17 00:44:21,640: 2023-06-17 00:44:21,640: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception 2023-06-17 00:44:21,640: util.raise( 2023-06-17 00:44:21,640: 2023-06-17 00:44:21,640: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 207, in raise_ 2023-06-17 00:44:21,640: raise exception 2023-06-17 00:44:21,640: 2023-06-17 00:44:21,641: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 983, in _rollback_impl 2023-06-17 00:44:21,641: self.engine.dialect.do_rollback(self.connection) 2023-06-17 00:44:21,642: 2023-06-17 00:44:21,642: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 682, in do_rollback 2023-06-17 00:44:21,643: dbapi_connection.rollback()

How is your database configured?

It is on mysql on pythonanywhere. Everything good.

I mean database configuration in your web app code.

.

Views = Blueprint("views", __name__)

uri = "mysql://andrehaffner:{SECRET_PASSWORD}@andrehaffner.mysql.pythonanywhere-services.com/andrehaffner$default"

app = Flask(__name__, template_folder='templates')

app.config["SECRET_KEY"] = "as@d145!sidh12*G3478"

app.config["SQLALCHEMY_DATABASE_URI"] = uri

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)


# ~~ Models ~~ #


class Certificate(db.Model):
    __tablename__ = 'certificates'
    id = db.Column(db.Integer, primary_key=True)
    course = db.Column(db.String)
    institution = db.Column(db.String)
    date_period = db.Column(db.String)
    image = db.Column(db.String)


class Education(db.Model):
    __tablename__ = 'education'
    id = db.Column(db.Integer, primary_key=True)
    diploma = db.Column(db.String)
    institution = db.Column(db.String)
    date_period = db.Column(db.String)
    image = db.Column(db.String)
    description = db.Column(db.String)


class Experience(db.Model):
    __tablename__ = 'professional'
    id = db.Column(db.Integer, primary_key=True)
    role = db.Column(db.String)
    company = db.Column(db.String)
    date_period = db.Column(db.String)
    image = db.Column(db.String)
    description = db.Column(db.String)

# ~~ Run ~~ #

if __name__ == "__main__":
    app.register_blueprint(Views, url_prefix="/")
    app.run(port=5432, debug=True)

First thing that catches my attention is lack of f before the quotation mark in the uri definition -- that would mean that you don't provide correct credentials. (Also, please don't post any secret keys/creds in public forums, if you don't want your data to be compromised).