fix: examples remove app context at the module level (#15546)

This commit is contained in:
Daniel Vaz Gaspar
2021-07-06 13:56:29 +01:00
committed by GitHub
parent 08bda27a43
commit 0af5a3d600
13 changed files with 101 additions and 73 deletions

View File

@@ -23,7 +23,7 @@ from sqlalchemy import String, Text
from superset import db
from superset.utils.core import get_example_database
from .helpers import get_example_data, TBL
from .helpers import get_example_data, get_table_connector_registry
def load_bart_lines(only_metadata: bool = False, force: bool = False) -> None:
@@ -53,9 +53,10 @@ def load_bart_lines(only_metadata: bool = False, force: bool = False) -> None:
)
print("Creating table {} reference".format(tbl_name))
tbl = db.session.query(TBL).filter_by(table_name=tbl_name).first()
table = get_table_connector_registry()
tbl = db.session.query(table).filter_by(table_name=tbl_name).first()
if not tbl:
tbl = TBL(table_name=tbl_name)
tbl = table(table_name=tbl_name)
tbl.description = "BART lines"
tbl.database = database
db.session.merge(tbl)