(Context: I am using flask and sqlalchemy. Not connecting to a external database, I am using Pythonanywhere's)
Hello everyone, I get this error only when doing raw queries:
Error running WSGI application
sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1226 (42000): User 'babisi' has exceeded the 'max_user_connections' resource (current value: 6)
(Background on this error at: https://sqlalche.me/e/14/f405)
I don't have this issue when using ORM. I always close my connections like this:
db.session.close()
db.session.close_all()
db.engine.dispose()
db.session.remove()
(it may be too much, but it has worked for me so far)
For the raw query I am doing something like this:
engine = create_engine(SQLALCHEMY_DATABASE_URI)
with engine.begin() as connection:
result = connection.execute(text(raw_query))
connection.close()
And even after that code section I close my connection like when using ORM.
I have googled a lot and read the oficial documentation for Sqlalchemy but no luck :(
Any help would be appreciated. Thanks!