Skip to content

Commit 348346d

Browse files
committed
fix: remove sqlite datasource
1 parent bcd758d commit 348346d

4 files changed

Lines changed: 1 addition & 25 deletions

File tree

backend/apps/datasource/crud/datasource.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
366366
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{table.table_name}"
367367
{where}
368368
LIMIT 100"""
369-
elif ds.type == "sqlite":
370-
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{table.table_name}"
371-
{where}
372-
LIMIT 100"""
373369
return exec_sql(ds, sql, True)
374370

375371

backend/apps/db/constant.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class DB(Enum):
2828
oracle = ('oracle', 'Oracle', '"', '"', ConnectType.sqlalchemy, 'Oracle', [])
2929
pg = ('pg', 'PostgreSQL', '"', '"', ConnectType.sqlalchemy, 'PostgreSQL', [])
3030
starrocks = ('starrocks', 'StarRocks', '`', '`', ConnectType.py_driver, 'StarRocks', [])
31-
sqlite = ('sqlite', 'SQLite', '"', '"', ConnectType.sqlalchemy, 'SQLite', [])
3231
hive = ('hive', 'Apache Hive', '`', '`', ConnectType.py_driver, 'Hive', [])
3332

3433
def __init__(self, type, db_name, prefix, suffix, connect_type: ConnectType, template_name: str,

backend/apps/db/db.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ def get_uri_from_config(type: str, conf: DatasourceConf) -> str:
9090
db_url = f"clickhouse+http://{urllib.parse.quote(conf.username)}:{urllib.parse.quote(conf.password)}@{conf.host}:{conf.port}/{conf.database}?{conf.extraJdbc}"
9191
else:
9292
db_url = f"clickhouse+http://{urllib.parse.quote(conf.username)}:{urllib.parse.quote(conf.password)}@{conf.host}:{conf.port}/{conf.database}"
93-
elif equals_ignore_case(type, "sqlite"):
94-
db_url = f"sqlite:///{conf.filename}"
9593
else:
9694
raise 'The datasource type not support.'
9795
return db_url
@@ -162,8 +160,6 @@ def get_engine(ds: CoreDatasource, timeout: int = 0) -> Engine:
162160
ssl_mode = {"require": True} if conf.ssl else None
163161
engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout, "ssl": ssl_mode},
164162
poolclass=NullPool)
165-
elif equals_ignore_case(ds.type, 'sqlite'):
166-
engine = create_engine(get_uri(ds), connect_args={"check_same_thread": False}, poolclass=NullPool)
167163
else: # ck
168164
engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool)
169165
return engine
@@ -357,8 +353,6 @@ def get_schema(ds: CoreDatasource):
357353
elif equals_ignore_case(ds.type, "oracle"):
358354
sql = """select *
359355
from all_users"""
360-
elif equals_ignore_case(ds.type, "sqlite"):
361-
return ['main']
362356
with session.execute(text(sql)) as result:
363357
res = result.fetchall()
364358
res_list = [item[0] for item in res]
@@ -464,10 +458,7 @@ def get_fields(ds: CoreDatasource, table_name: str = None):
464458
with get_session(ds) as session:
465459
with session.execute(text(sql), {"param1": p1, "param2": p2}) as result:
466460
res = result.fetchall()
467-
if equals_ignore_case(ds.type, "sqlite"):
468-
res_list = [ColumnSchema(item[1], item[2], '') for item in res]
469-
else:
470-
res_list = [ColumnSchema(*item) for item in res]
461+
res_list = [ColumnSchema(*item) for item in res]
471462
return res_list
472463
else:
473464
extra_config_dict = get_extra_config(conf)

backend/apps/db/db_sql.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@ def get_table_sql(ds: CoreDatasource, conf: DatasourceConf, db_version: str = ''
162162
""", conf.dbSchema
163163
elif equals_ignore_case(ds.type, "es"):
164164
return "", None
165-
elif equals_ignore_case(ds.type, "sqlite"):
166-
return """
167-
SELECT name AS TABLE_NAME, ''
168-
FROM sqlite_master
169-
WHERE type='table'
170-
ORDER BY name
171-
""", None
172165
elif equals_ignore_case(ds.type, "hive"):
173166
return """
174167
SHOW TABLES
@@ -323,9 +316,6 @@ def get_field_sql(ds: CoreDatasource, conf: DatasourceConf, table_name: str = No
323316
return sql1 + sql2, conf.dbSchema, table_name
324317
elif equals_ignore_case(ds.type, "es"):
325318
return "", None, None
326-
elif equals_ignore_case(ds.type, "sqlite"):
327-
sql1 = f"PRAGMA table_info({table_name})"
328-
return sql1, None, None
329319
elif equals_ignore_case(ds.type, "hive"):
330320
sql1 = f"DESCRIBE {table_name}"
331321
return sql1, None, None

0 commit comments

Comments
 (0)