mcp-dbutils 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_dbutils/base.py +17 -7
- {mcp_dbutils-1.0.1.dist-info → mcp_dbutils-1.0.3.dist-info}/METADATA +1 -1
- {mcp_dbutils-1.0.1.dist-info → mcp_dbutils-1.0.3.dist-info}/RECORD +6 -6
- {mcp_dbutils-1.0.1.dist-info → mcp_dbutils-1.0.3.dist-info}/WHEEL +0 -0
- {mcp_dbutils-1.0.1.dist-info → mcp_dbutils-1.0.3.dist-info}/entry_points.txt +0 -0
- {mcp_dbutils-1.0.1.dist-info → mcp_dbutils-1.0.3.dist-info}/licenses/LICENSE +0 -0
mcp_dbutils/base.py
CHANGED
@@ -569,6 +569,7 @@ class ConnectionServer:
|
|
569
569
|
"""Extract table name from SQL statement
|
570
570
|
|
571
571
|
This is a simple implementation that works for basic SQL statements.
|
572
|
+
Handles multi-line SQL statements by normalizing whitespace.
|
572
573
|
|
573
574
|
Args:
|
574
575
|
sql: SQL statement
|
@@ -577,23 +578,26 @@ class ConnectionServer:
|
|
577
578
|
str: Table name
|
578
579
|
"""
|
579
580
|
sql_type = self._get_sql_type(sql)
|
580
|
-
|
581
|
+
|
582
|
+
# 预处理SQL:规范化空白字符,将多行SQL转换为单行
|
583
|
+
# 将所有连续的空白字符(包括换行符、制表符等)替换为单个空格
|
584
|
+
normalized_sql = " ".join(sql.split())
|
581
585
|
|
582
586
|
if sql_type == "INSERT":
|
583
587
|
# INSERT INTO table_name ...
|
584
|
-
match =
|
588
|
+
match = normalized_sql.upper().split("INTO", 1)
|
585
589
|
if len(match) > 1:
|
586
590
|
table_part = match[1].strip().split(" ", 1)[0]
|
587
591
|
return table_part.strip('`"[]')
|
588
592
|
elif sql_type == "UPDATE":
|
589
593
|
# UPDATE table_name ...
|
590
|
-
match =
|
594
|
+
match = normalized_sql.upper().split("UPDATE", 1)
|
591
595
|
if len(match) > 1:
|
592
596
|
table_part = match[1].strip().split(" ", 1)[0]
|
593
597
|
return table_part.strip('`"[]')
|
594
598
|
elif sql_type == "DELETE":
|
595
599
|
# DELETE FROM table_name ...
|
596
|
-
match =
|
600
|
+
match = normalized_sql.upper().split("FROM", 1)
|
597
601
|
if len(match) > 1:
|
598
602
|
table_part = match[1].strip().split(" ", 1)[0]
|
599
603
|
return table_part.strip('`"[]')
|
@@ -625,6 +629,9 @@ class ConnectionServer:
|
|
625
629
|
# 没有细粒度权限控制,默认允许所有写操作
|
626
630
|
return
|
627
631
|
|
632
|
+
# 将表名转换为小写,用于大小写不敏感的比较
|
633
|
+
table_name_lower = table_name.lower()
|
634
|
+
|
628
635
|
# 检查表级权限
|
629
636
|
tables = write_permissions.get("tables", {})
|
630
637
|
if not tables:
|
@@ -638,9 +645,12 @@ class ConnectionServer:
|
|
638
645
|
operation=operation_type, table=table_name
|
639
646
|
))
|
640
647
|
|
641
|
-
#
|
642
|
-
|
643
|
-
|
648
|
+
# 创建表名到配置的映射,支持大小写不敏感的比较
|
649
|
+
tables_lower = {k.lower(): v for k, v in tables.items()}
|
650
|
+
|
651
|
+
# 检查特定表的权限(大小写不敏感)
|
652
|
+
if table_name_lower in tables_lower:
|
653
|
+
table_config = tables_lower[table_name_lower]
|
644
654
|
operations = table_config.get("operations", ["INSERT", "UPDATE", "DELETE"])
|
645
655
|
if operation_type in operations:
|
646
656
|
return
|
@@ -1,6 +1,6 @@
|
|
1
1
|
mcp_dbutils/__init__.py,sha256=6LLccQv7je2L4IpY_I3OzSJZcK32VUDJv2IY31y6eYg,1900
|
2
2
|
mcp_dbutils/audit.py,sha256=U-Fd511HxOQH4BxfCXgd4KyaBLESEBnGsPkUNviSTwc,7294
|
3
|
-
mcp_dbutils/base.py,sha256=
|
3
|
+
mcp_dbutils/base.py,sha256=oOoKdBbHLB3PfuhQ_fZXZz-4G8df4q5HeZPB4U45HKs,62206
|
4
4
|
mcp_dbutils/config.py,sha256=zwN9yPKv4WvEPG3WIRT6uBVZSRxFniSmN2kEog7KPcI,5921
|
5
5
|
mcp_dbutils/log.py,sha256=mqxi6I_IL-MF1F_pxBtnYZQKOHbGBJ74gsvZHVelr1w,823
|
6
6
|
mcp_dbutils/stats.py,sha256=wMqWPfGnEOg9v5YBtTsARV-1YsFUMM_pKdzitzSU9x4,7137
|
@@ -16,8 +16,8 @@ mcp_dbutils/sqlite/__init__.py,sha256=fK_3-WylCBYpBAzwuopi8hlwoIGJm2TPAlwcPWG46I
|
|
16
16
|
mcp_dbutils/sqlite/config.py,sha256=rsfAE8yaCVZC39ziXssqsi0EXUOEWA-MtKHvrO-6jG4,4933
|
17
17
|
mcp_dbutils/sqlite/handler.py,sha256=vpkyCow26hpBqigNUNW0VGyWhsTz8uFflssM7K-FJi4,21882
|
18
18
|
mcp_dbutils/sqlite/server.py,sha256=EBKNKz_wTvChwg6BZlvZIBA1H5mmE2NiNEMOgu_CMy4,7373
|
19
|
-
mcp_dbutils-1.0.
|
20
|
-
mcp_dbutils-1.0.
|
21
|
-
mcp_dbutils-1.0.
|
22
|
-
mcp_dbutils-1.0.
|
23
|
-
mcp_dbutils-1.0.
|
19
|
+
mcp_dbutils-1.0.3.dist-info/METADATA,sha256=xvp1x0QBA1tHw04kx__QfK9wpsahjMNoO_6knPsXaBg,8440
|
20
|
+
mcp_dbutils-1.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
21
|
+
mcp_dbutils-1.0.3.dist-info/entry_points.txt,sha256=XTjt0QmYRgKOJQT6skR9bp1EMUfIrgpHeZJPZ3CJffs,49
|
22
|
+
mcp_dbutils-1.0.3.dist-info/licenses/LICENSE,sha256=1A_CwpWVlbjrKdVEYO77vYfnXlW7oxcilZ8FpA_BzCI,1065
|
23
|
+
mcp_dbutils-1.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|