mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
fix: remove sqlite datasource
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
+1
-10
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user