platypush/platypush/common/db.py
Fabio Manganiello d33d760361
Better way to import declarative_base from SQLAlchemy.
Import `declarative_base` in a way that is compatible with any
SQLAlchemy version between 1.3 and 2.x.
2023-04-24 23:23:55 +02:00

10 lines
259 B
Python

from sqlalchemy import __version__
sa_version = tuple(map(int, __version__.split('.')))
if sa_version >= (1, 4, 0):
from sqlalchemy.orm import declarative_base
else:
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()