From a21092b7e087f39c152377602964493db540bd42 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 31 May 2021 12:13:23 -0700 Subject: [PATCH] Touch up db submodule --- amanuensis/db/__init__.py | 18 +++++++++++++++++- amanuensis/db/database.py | 5 +++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/amanuensis/db/__init__.py b/amanuensis/db/__init__.py index 09192ae..ecec332 100644 --- a/amanuensis/db/__init__.py +++ b/amanuensis/db/__init__.py @@ -12,4 +12,20 @@ from .models import ( ArticleContentRuleType, ArticleContentRule, Post, -) \ No newline at end of file +) + +__all__ = [ + 'DbContext', + 'User', + 'Lexicon', + 'Membership', + 'Character', + 'ArticleState', + 'Article', + 'IndexType', + 'ArticleIndex', + 'ArticleIndexRule', + 'ArticleContentRuleType', + 'ArticleContentRule', + 'Post', +] \ No newline at end of file diff --git a/amanuensis/db/database.py b/amanuensis/db/database.py index 22647a6..988a6ba 100644 --- a/amanuensis/db/database.py +++ b/amanuensis/db/database.py @@ -33,5 +33,10 @@ class DbContext(): # Create a thread-safe session factory self.session = scoped_session(sessionmaker(bind=self.engine)) + def __call__(self, *args, **kwargs): + """Provides shortcut access to session.execute.""" + return self.session.execute(*args, **kwargs) + def create_all(self): + """Initializes the database schema.""" ModelBase.metadata.create_all(self.engine)