pauldex / sqlalchemy-firebird

A Firebird dialect for SQLAlchemy using the firebird-driver and/or fdb python Firebird driver
MIT License
22 stars 15 forks source link

caching warning from SQLAlchemy 1.4 #36

Closed hmoffatt closed 2 years ago

hmoffatt commented 2 years ago

Describe the bug A clear and concise description of what the bug is. Since upgrading to SQLAlchemy 1.4, it outputs the following warning when using sqlalchemy-firebird:

SAWarning: Dialect firebird:fdb will not make use of SQL compilation caching as it does not set the 'supports_statement_cache' attribute to ``True``.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Dialect maintainers should seek to set this attribute to True after appropriate development and testing for SQLAlchemy 1.4 caching support.   Alternatively, this attribute may be set to False which will disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)

To Reproduce

import sys
import flask
import os
import os.path
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)

app.config.setdefault('DB_PATH', os.getcwd())
app.config.setdefault('SESSION_DB_HOST', 'localhost')
app.config.setdefault('SESSION_DB', 'db/sessions.fdb')
app.config.setdefault('FIREBIRD_USER', 'sysdba')
app.config.setdefault('FIREBIRD_PASSWORD', 'masterkey')

app.config.setdefault('SQLALCHEMY_DATABASE_URI', 'firebird+fdb://%s:%s@%s/%s'
                      % (app.config['FIREBIRD_USER'],
                         app.config['FIREBIRD_PASSWORD'],
                          app.config['SESSION_DB_HOST'],
                          os.path.join(app.config['DB_PATH'], app.config['SESSION_DB'])))

session_db = SQLAlchemy()
session_db.init_app(app)

with app.app_context():
    # session_db.engine.echo = True
    session_db.metadata.bind = session_db.engine
    session_db.metadata.reflect()