Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Adds the option to supress MetaData.create_all call #69

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading