@@ -131,7 +131,7 @@ def get_simple_ds_list(self):
131131 def get_db_schema (self , ds_id : int ) -> str :
132132 ds = self .get_ds (ds_id )
133133 schema_str = ""
134- db_name = ds .schema
134+ db_name = ds .db_schema
135135 schema_str += f"【DB_ID】 { db_name } \n 【Schema】\n "
136136 for table in ds .tables :
137137 schema_str += f"# Table: { db_name } .{ table .name } "
@@ -159,7 +159,9 @@ def convert2schema(self, ds_dict: dict) -> AssistantOutDsSchema:
159159 if attr in ds_dict :
160160 id_marker += str (ds_dict .get (attr , '' )) + '--sqlbot--'
161161 id = string_to_numeric_hash (id_marker )
162- return AssistantOutDsSchema (** {** ds_dict , "id" : id })
162+ db_schema = ds_dict .get ('schema' , ds_dict .get ('db_schema' , '' ))
163+ ds_dict .pop ("schema" , None )
164+ return AssistantOutDsSchema (** {** ds_dict , "id" : id , "db_schema" : db_schema })
163165
164166class AssistantOutDsFactory :
165167 @staticmethod
@@ -177,12 +179,12 @@ def get_ds_engine(ds: AssistantOutDsSchema) -> Engine:
177179 database = ds .dataBase ,
178180 driver = '' ,
179181 extraJdbc = ds .extraParams ,
180- dbSchema = ds .schema or ''
182+ dbSchema = ds .db_schema or ''
181183 )
182184 from apps .db .db import get_uri_from_config
183185 uri = get_uri_from_config (ds .type , conf )
184- if ds .type == "pg" and ds .schema :
185- connect_args .update ({"options" : f"-c search_path={ ds .schema } " })
186+ if ds .type == "pg" and ds .db_schema :
187+ connect_args .update ({"options" : f"-c search_path={ ds .db_schema } " })
186188 engine = create_engine (uri , connect_args = connect_args , pool_timeout = timeout , pool_size = 20 , max_overflow = 10 )
187189 return engine
188190
0 commit comments