mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore(sqllab): Cleanup /tables/... endpoint (#21284)
This commit is contained in:
@@ -31,7 +31,6 @@ from flask_appbuilder.api.manager import resolver
|
||||
|
||||
import superset.utils.database as database_utils
|
||||
from superset.extensions import db
|
||||
from superset.utils.core import override_user
|
||||
from superset.utils.encrypt import SecretsMigrator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -53,38 +52,6 @@ def set_database_uri(database_name: str, uri: str, skip_create: bool) -> None:
|
||||
database_utils.get_or_create_db(database_name, uri, not skip_create)
|
||||
|
||||
|
||||
@click.command()
|
||||
@with_appcontext
|
||||
@click.option(
|
||||
"--username",
|
||||
"-u",
|
||||
default=None,
|
||||
help=(
|
||||
"Specify which user should execute the underlying SQL queries. If undefined "
|
||||
"defaults to the user registered with the database connection."
|
||||
),
|
||||
)
|
||||
def update_datasources_cache(username: Optional[str]) -> None:
|
||||
"""Refresh sqllab datasources cache"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from superset import security_manager
|
||||
from superset.models.core import Database
|
||||
|
||||
with override_user(security_manager.find_user(username)):
|
||||
for database in db.session.query(Database).all():
|
||||
if database.allow_multi_schema_metadata_fetch:
|
||||
print("Fetching {} datasources ...".format(database.name))
|
||||
try:
|
||||
database.get_all_table_names_in_database(
|
||||
force=True, cache=True, cache_timeout=24 * 60 * 60
|
||||
)
|
||||
database.get_all_view_names_in_database(
|
||||
force=True, cache=True, cache_timeout=24 * 60 * 60
|
||||
)
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
print("{}".format(str(ex)))
|
||||
|
||||
|
||||
@click.command()
|
||||
@with_appcontext
|
||||
def sync_tags() -> None:
|
||||
|
||||
Reference in New Issue
Block a user