I registered my custom range type using register_range with flask-sqlalchemy
2: what you expected to happen
I expected my custom range type will be registered correctly.
3: what happened instead
I got the following error.
File "/usr/local/app/app.py", line 22, in <module>
TimeRange.register(engine)
File "/usr/local/app/app.py", line 11, in register
register_range('timerange', cls, conn, globally=True)
File "/home/user/.cache/pypoetry/virtualenvs/wifishare-pyapi-woE4c0CP-py3.11/lib/python3.11/site-packages/psycopg2/_range.py", line 232, in register_range
caster = RangeCaster._from_db(pgrange, pyrange, conn_or_curs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.cache/pypoetry/virtualenvs/wifishare-pyapi-woE4c0CP-py3.11/lib/python3.11/site-packages/psycopg2/_range.py", line 351, in _from_db
if conn.info.server_version < 90200:
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'server_version'
If possible, provide a script reproducing the issue.
from psycopg2.extras import Range
from psycopg2.extras import register_range
class TimeRange(Range):
@classmethod
def register(cls, engine):
conn = engine.raw_connection()
register_range('timerange', cls, conn, globally=True)
conn.close()
db = SQLAlchemy(session_options={})
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://username:password@localhost:port/DBNAME'
db.init_app(app)
engine = db.get_engine(app)
TimeRange.register(engine)
Please complete the following information:
Describe the bug
Please let us know:
1: what you did
I registered my custom range type using register_range with flask-sqlalchemy
2: what you expected to happen
I expected my custom range type will be registered correctly.
3: what happened instead
I got the following error.
If possible, provide a script reproducing the issue.
flask: 2.0.0 flask-sqlalchemy: 2.5.0 sqlalchemy: 1.4.52