Touch up db submodule

This commit is contained in:
Tim Van Baak 2021-05-31 12:13:23 -07:00
parent 5f879cd062
commit a21092b7e0
2 changed files with 22 additions and 1 deletions

View File

@ -12,4 +12,20 @@ from .models import (
ArticleContentRuleType, ArticleContentRuleType,
ArticleContentRule, ArticleContentRule,
Post, Post,
) )
__all__ = [
'DbContext',
'User',
'Lexicon',
'Membership',
'Character',
'ArticleState',
'Article',
'IndexType',
'ArticleIndex',
'ArticleIndexRule',
'ArticleContentRuleType',
'ArticleContentRule',
'Post',
]

View File

@ -33,5 +33,10 @@ class DbContext():
# Create a thread-safe session factory # Create a thread-safe session factory
self.session = scoped_session(sessionmaker(bind=self.engine)) 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): def create_all(self):
"""Initializes the database schema."""
ModelBase.metadata.create_all(self.engine) ModelBase.metadata.create_all(self.engine)