From 348346d97b50a5b041b5b4d55e70a4e91e59f3ea Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 4 Jun 2026 11:40:31 +0800 Subject: [PATCH] fix: remove sqlite datasource --- backend/apps/datasource/crud/datasource.py | 4 ---- backend/apps/db/constant.py | 1 - backend/apps/db/db.py | 11 +---------- backend/apps/db/db_sql.py | 10 ---------- 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/backend/apps/datasource/crud/datasource.py b/backend/apps/datasource/crud/datasource.py index 48ab794b..acd7522e 100644 --- a/backend/apps/datasource/crud/datasource.py +++ b/backend/apps/datasource/crud/datasource.py @@ -366,10 +366,6 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table sql = f"""SELECT "{'", "'.join(fields)}" FROM "{table.table_name}" {where} LIMIT 100""" - elif ds.type == "sqlite": - sql = f"""SELECT "{'", "'.join(fields)}" FROM "{table.table_name}" - {where} - LIMIT 100""" return exec_sql(ds, sql, True) diff --git a/backend/apps/db/constant.py b/backend/apps/db/constant.py index 6ee33f02..dcec8190 100644 --- a/backend/apps/db/constant.py +++ b/backend/apps/db/constant.py @@ -28,7 +28,6 @@ class DB(Enum): oracle = ('oracle', 'Oracle', '"', '"', ConnectType.sqlalchemy, 'Oracle', []) pg = ('pg', 'PostgreSQL', '"', '"', ConnectType.sqlalchemy, 'PostgreSQL', []) starrocks = ('starrocks', 'StarRocks', '`', '`', ConnectType.py_driver, 'StarRocks', []) - sqlite = ('sqlite', 'SQLite', '"', '"', ConnectType.sqlalchemy, 'SQLite', []) hive = ('hive', 'Apache Hive', '`', '`', ConnectType.py_driver, 'Hive', []) def __init__(self, type, db_name, prefix, suffix, connect_type: ConnectType, template_name: str, diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index b87ff789..d8127f36 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -90,8 +90,6 @@ def get_uri_from_config(type: str, conf: DatasourceConf) -> str: db_url = f"clickhouse+http://{urllib.parse.quote(conf.username)}:{urllib.parse.quote(conf.password)}@{conf.host}:{conf.port}/{conf.database}?{conf.extraJdbc}" else: db_url = f"clickhouse+http://{urllib.parse.quote(conf.username)}:{urllib.parse.quote(conf.password)}@{conf.host}:{conf.port}/{conf.database}" - elif equals_ignore_case(type, "sqlite"): - db_url = f"sqlite:///{conf.filename}" else: raise 'The datasource type not support.' return db_url @@ -162,8 +160,6 @@ def get_engine(ds: CoreDatasource, timeout: int = 0) -> Engine: ssl_mode = {"require": True} if conf.ssl else None engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout, "ssl": ssl_mode}, poolclass=NullPool) - elif equals_ignore_case(ds.type, 'sqlite'): - engine = create_engine(get_uri(ds), connect_args={"check_same_thread": False}, poolclass=NullPool) else: # ck engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool) return engine @@ -357,8 +353,6 @@ def get_schema(ds: CoreDatasource): elif equals_ignore_case(ds.type, "oracle"): sql = """select * from all_users""" - elif equals_ignore_case(ds.type, "sqlite"): - return ['main'] with session.execute(text(sql)) as result: res = result.fetchall() res_list = [item[0] for item in res] @@ -464,10 +458,7 @@ def get_fields(ds: CoreDatasource, table_name: str = None): with get_session(ds) as session: with session.execute(text(sql), {"param1": p1, "param2": p2}) as result: res = result.fetchall() - if equals_ignore_case(ds.type, "sqlite"): - res_list = [ColumnSchema(item[1], item[2], '') for item in res] - else: - res_list = [ColumnSchema(*item) for item in res] + res_list = [ColumnSchema(*item) for item in res] return res_list else: extra_config_dict = get_extra_config(conf) diff --git a/backend/apps/db/db_sql.py b/backend/apps/db/db_sql.py index fa790c8a..49607537 100644 --- a/backend/apps/db/db_sql.py +++ b/backend/apps/db/db_sql.py @@ -162,13 +162,6 @@ def get_table_sql(ds: CoreDatasource, conf: DatasourceConf, db_version: str = '' """, conf.dbSchema elif equals_ignore_case(ds.type, "es"): return "", None - elif equals_ignore_case(ds.type, "sqlite"): - return """ - SELECT name AS TABLE_NAME, '' - FROM sqlite_master - WHERE type='table' - ORDER BY name - """, None elif equals_ignore_case(ds.type, "hive"): return """ SHOW TABLES @@ -323,9 +316,6 @@ def get_field_sql(ds: CoreDatasource, conf: DatasourceConf, table_name: str = No return sql1 + sql2, conf.dbSchema, table_name elif equals_ignore_case(ds.type, "es"): return "", None, None - elif equals_ignore_case(ds.type, "sqlite"): - sql1 = f"PRAGMA table_info({table_name})" - return sql1, None, None elif equals_ignore_case(ds.type, "hive"): sql1 = f"DESCRIBE {table_name}" return sql1, None, None