Skip to content

Commit

Permalink
feat: DeclarativeBase import fails with SQLAlchemy 1.x (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Donoghue <sean.donoghue@pm.me>
  • Loading branch information
sean-donoghue authored Mar 28, 2024
1 parent b6bfd80 commit 8b03bab
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions casbin_sqlalchemy_adapter/adapter.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from contextlib import contextmanager

import sqlalchemy
from casbin import persist
from sqlalchemy import Column, Integer, String
from sqlalchemy import create_engine, or_
from sqlalchemy.orm import sessionmaker, DeclarativeBase
from sqlalchemy.orm import sessionmaker

# declarative base class
class Base(DeclarativeBase):
pass
if sqlalchemy.__version__.startswith("1."):
from sqlalchemy.orm import declarative_base

Base = declarative_base()

else:
from sqlalchemy.orm import DeclarativeBase

class Base(DeclarativeBase):
pass


class CasbinRule(Base):
Expand Down

0 comments on commit 8b03bab

Please # to comment.