Skip to content

Commit

Permalink
feat: Add the option to suppress MetaData.create_all call
Browse files Browse the repository at this point in the history
  • Loading branch information
trbtm committed Jul 5, 2024
1 parent 0e29b6f commit e99744f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions casbin_sqlalchemy_adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Filter:
class Adapter(persist.Adapter, persist.adapters.UpdateAdapter):
"""the interface for Casbin adapters."""

def __init__(self, engine, db_class=None, filtered=False):
def __init__(self, engine, db_class=None, filtered=False, create_all_models=True):
if isinstance(engine, str):
self._engine = create_engine(engine)
else:
Expand All @@ -82,7 +82,8 @@ def __init__(self, engine, db_class=None, filtered=False):
self._db_class = db_class
self.session_local = sessionmaker(bind=self._engine)

Base.metadata.create_all(self._engine)
if create_all_models:
Base.metadata.create_all(self._engine)
self._filtered = filtered

@contextmanager
Expand Down

0 comments on commit e99744f

Please # to comment.