Touch up db submodule
This commit is contained in:
parent
5f879cd062
commit
a21092b7e0
|
@ -13,3 +13,19 @@ from .models import (
|
||||||
ArticleContentRule,
|
ArticleContentRule,
|
||||||
Post,
|
Post,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'DbContext',
|
||||||
|
'User',
|
||||||
|
'Lexicon',
|
||||||
|
'Membership',
|
||||||
|
'Character',
|
||||||
|
'ArticleState',
|
||||||
|
'Article',
|
||||||
|
'IndexType',
|
||||||
|
'ArticleIndex',
|
||||||
|
'ArticleIndexRule',
|
||||||
|
'ArticleContentRuleType',
|
||||||
|
'ArticleContentRule',
|
||||||
|
'Post',
|
||||||
|
]
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue