@@ -67,11 +67,9 @@ def _post_init(self):
6767 from vanna .tools import LocalFileSystem
6868 from vanna .integrations .local .agent_memory import DemoAgentMemory
6969
70- # 验证连接字符串格式
7170 if not self .connection_string :
7271 raise ValueError ("Connection string cannot be empty" )
7372
74- # 检查连接字符串格式
7573 if self .connection_string .startswith ("sqlite://" ):
7674 if len (self .connection_string ) <= len ("sqlite://" ):
7775 raise ValueError (
@@ -133,41 +131,32 @@ def _post_init(self):
133131 try :
134132 from urllib .parse import urlparse , parse_qs
135133
136- # 解析 URI
137134 parsed = urlparse (self .connection_string )
138135
139- # 提取基本信息
140136 user = parsed .username
141137 password = parsed .password
142138 host = parsed .hostname
143- port = parsed .port or 8123 # 默认端口
139+ port = parsed .port or 8123
144140 database = parsed .path .lstrip ("/" )
145141
146- # 解析查询参数
147142 query_params = parse_qs (parsed .query )
148143 kwargs = {}
149144
150- # 处理所有查询参数
151145 for key , values in query_params .items ():
152146 if not values :
153147 continue
154148
155- value = values [0 ] # 取第一个值
149+ value = values [0 ]
156150
157- # 处理布尔值参数
158151 if value .lower () in ("true" , "false" , "1" , "0" , "yes" , "no" ):
159152 kwargs [key ] = value .lower () in ("true" , "1" , "yes" )
160- # 处理数字参数
161153 elif value .isdigit ():
162154 kwargs [key ] = int (value )
163- # 处理浮点数参数
164155 elif value .replace ("." , "" , 1 ).isdigit ():
165156 kwargs [key ] = float (value )
166- # 其他参数保持字符串
167157 else :
168158 kwargs [key ] = value
169159
170- # 验证必需参数
171160 if not all ([user , password , host , database ]):
172161 raise ValueError (
173162 "Missing required connection parameters (user, password, host, database)"
0 commit comments