Cleanup __init__ and add functions to convert SQLAchemy results into dict.
This commit is contained in:
parent
01a509d348
commit
b436e0aa06
@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
# vim: set tw=80 ts=4 sw=4 sts=4:
|
# vim: set tw=80 ts=4 sw=4 sts=4:
|
||||||
|
|
||||||
import pkgutil
|
|
||||||
|
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
|
|
||||||
__all__ = ['db']
|
|
||||||
|
|
||||||
for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
|
def row_as_dict(row):
|
||||||
__all__.append(module_name)
|
"""Return a SQLAlchemy row as dict."""
|
||||||
|
return dict(zip(row.keys(), row))
|
||||||
|
|
||||||
|
|
||||||
|
def result_as_dicts(query):
|
||||||
|
"""Return SQLAlchemy query results as dictionnaries."""
|
||||||
|
for row in query.all():
|
||||||
|
yield row_as_dict(row)
|
||||||
|
Loading…
Reference in New Issue
Block a user