Skip to content

Commit 06a29a9

Browse files
committed
feat: Ask to add database version information
1 parent 86c85d6 commit 06a29a9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

backend/apps/db/db.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def check_connection(trans: Trans, ds: CoreDatasource, is_raise: bool = False):
156156

157157

158158
def get_version(ds: CoreDatasource | AssistantOutDsSchema):
159+
version = ''
159160
conf = None
160161
if isinstance(ds, CoreDatasource):
161162
conf = DatasourceConf(
@@ -176,26 +177,27 @@ def get_version(ds: CoreDatasource | AssistantOutDsSchema):
176177
with get_session(ds) as session:
177178
with session.execute(text(sql)) as result:
178179
res = result.fetchall()
179-
return res[0][0]
180+
version = res[0][0]
180181
else:
181182
if ds.type == 'dm':
182183
with dmPython.connect(user=conf.username, password=conf.password, server=conf.host,
183184
port=conf.port) as conn, conn.cursor() as cursor:
184185
cursor.execute(sql, timeout=10)
185186
res = cursor.fetchall()
186-
return res[0][0]
187+
version = res[0][0]
187188
elif ds.type == 'doris':
188189
with pymysql.connect(user=conf.username, passwd=conf.password, host=conf.host,
189190
port=conf.port, db=conf.database, connect_timeout=10,
190191
read_timeout=10) as conn, conn.cursor() as cursor:
191192
cursor.execute(sql)
192193
res = cursor.fetchall()
193-
return res[0][0]
194+
version = res[0][0]
194195
elif ds.type == 'redshift':
195-
return ''
196+
version = ''
196197
except Exception as e:
197198
print(e)
198-
return ''
199+
version = ''
200+
return version.decode() if isinstance(version, bytes) else version
199201

200202

201203
def get_schema(ds: CoreDatasource):

0 commit comments

Comments
 (0)