Skip to content

Commit

Permalink
showTableName
Browse files Browse the repository at this point in the history
  • Loading branch information
feiazifeiazi committed Dec 27, 2024
1 parent d97ccdc commit a6b8497
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions sql/engines/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ def get_all_databases(self, **kwargs):
result.rows = db_list
return result

def get_all_tables(self, db_name, **kwargs):
"""获取表列表。Redis的key可以理为表。方法只扫描部分表。起到预览作用。"""
result = ResultSet(full_sql="")
max_results = 100
table_info_list = []
try:
conn = self.get_connection(db_name)
scan_rows = conn.scan_iter(match=None, count=20)
for idx, key in enumerate(scan_rows):
if idx >= max_results:
break
table_info_list.append(key)
except Exception as e:
logger.error(f"get_all_tables执行报错,异常信息:{e}")
result.message = f"{e}"
result.rows = table_info_list
return result

def query_check(self, db_name=None, sql="", limit_num=0):
"""提交查询前的检查"""
result = {"msg": "", "bad_query": True, "filtered_sql": sql, "has_star": False}
Expand Down
2 changes: 1 addition & 1 deletion sql/templates/sqlquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ <h4 class="modal-title text-danger">收藏语句</h4>
}
const engineDisplayConfig = {
"MsSQL": createDisplayConfig({showExplain: false}),
"Redis": createDisplayConfig({showTableName: false, showSchemaName: false,
"Redis": createDisplayConfig({showTableName: true, showSchemaName: false,
showRedisHelp: true,
showFormat: false, showExplain: false}),
"PgSQL": createDisplayConfig({showSchemaName: true}),
Expand Down

0 comments on commit a6b8497

Please sign in to comment.