Qianhui19 commited on
Commit
556dcc6
·
verified ·
1 Parent(s): e38c1d4

Update schema_tool.txt

Browse files
Files changed (1) hide show
  1. schema_tool.txt +179 -179
schema_tool.txt CHANGED
@@ -1,179 +1,179 @@
1
- openapi: 3.0.1
2
- info:
3
- title: SQL Executor for Dual Databases
4
- description: |
5
- Execute read-only SQL queries on two specialized databases and return structured JSON results:
6
- - pubchemlite: Compound basic information database (core table: pubchemlite_exposomics_20251226)
7
- - invitrodb_v4_3: In vitro toxicity experiment database (core tables: assay, chemical, mc0, assay_component)
8
- (Adapted for local/server Flask API, only SELECT queries supported, write/modify operations prohibited)
9
- version: 1.0.0
10
- servers:
11
- - url: http://192.168.0.179:5000
12
- description: Main API Server
13
- paths:
14
- /execute_sql:
15
- post:
16
- summary: Execute SELECT query on specified database
17
- operationId: executeSqlPost
18
- description: |
19
- Execute read-only SELECT queries on pubchemlite or invitrodb_v4_3 database.
20
- Notes:
21
- 1. Only SELECT operation is allowed (INSERT/UPDATE/DELETE/DROP are prohibited);
22
- 2. For fields with special characters (e.g. pred_CCS_A2_[M+H]+ in pubchemlite), escape []/+ with backslash (\) or use backticks (`);
23
- 3. Avoid Python format characters (%, A, s, d) in SQL to prevent parsing errors;
24
- 4. Add LIMIT clause to avoid large result sets (recommended LIMIT 100).
25
- requestBody:
26
- required: true
27
- content:
28
- application/json:
29
- schema:
30
- type: object
31
- properties:
32
- db_identifier:
33
- type: string
34
- description: Target database identifier (case-sensitive)
35
- enum: [pubchemlite, invitrodb_v4_3]
36
- example: "pubchemlite"
37
- x-validation: "Must be one of the specified enum values"
38
- sql:
39
- type: string
40
- description: |
41
- Valid MySQL SELECT query (only):
42
- ## pubchemlite (core table: pubchemlite_exposomics_20251226)
43
- Key fields:
44
- - Basic info: Identifier, CompoundName, MolecularFormula, SMILES, XLogP
45
- - Literature/Patent: PubMed_Count, Patent_Count
46
- - Toxicity/Property: SafetyInfo, ToxicityInfo, MonoisotopicMass
47
- - Predicted CCS: pred_CCS_A2_[M+H]+, pred_CCS_A2_[M+Na]+, pred_CCS_A2_[M-H]- (escape special chars!)
48
-
49
- ## invitrodb_v4_3 (core tables)
50
- - assay: aid, assay_name, organism, tissue, ncbi_taxon_id
51
- - chemical: chid, casn, chnm (chemical name), dsstox_substance_id
52
- - mc0: m0id, acid, spid, conc (concentration μM), rval (response value)
53
- - assay_component: acid, assay_component_name (toxicity type)
54
- examples:
55
- pubchemlite_example:
56
- summary: Query compound basic info (with escaped special field)
57
- value: "SELECT Identifier, CompoundName, `pred_CCS_A2_[M+H]+` FROM pubchemlite_exposomics_20251226 WHERE PubMed_Count > 5 LIMIT 10"
58
- invitrodb_example:
59
- summary: Query human in vitro toxicity data
60
- value: "SELECT c.chnm, a.assay_name, m.conc, m.rval FROM chemical c JOIN mc0 m ON c.dsstox_substance_id = m.dsstox_substance_id JOIN assay a ON m.aid = a.aid WHERE a.ncbi_taxon_id = 9606 LIMIT 10"
61
- required:
62
- - db_identifier
63
- - sql
64
- x-error-tips: |
65
- 1. Missing required parameters: Ensure both db_identifier and sql are provided;
66
- 2. Invalid db_identifier: Only pubchemlite/invitrodb_v4_3 are allowed;
67
- 3. SQL syntax error: Check field/table names and special character escaping.
68
- responses:
69
- '200':
70
- description: Query executed successfully (returns array of records)
71
- content:
72
- application/json:
73
- schema:
74
- type: object
75
- properties:
76
- status:
77
- type: string
78
- enum: [success, error]
79
- description: Execution status
80
- data:
81
- type: array
82
- items:
83
- type: object
84
- description: Query results (key = field name, value = field value)
85
- additionalProperties: true
86
- message:
87
- type: string
88
- description: Error message (empty if success)
89
- examples:
90
- pubchemlite_response:
91
- summary: pubchemlite query success
92
- value:
93
- status: "success"
94
- data: [
95
- {
96
- "Identifier": "CID12345",
97
- "CompoundName": "Aspirin",
98
- "MolecularFormula": "C9H8O4",
99
- "pred_CCS_A2_[M+H]+": 181.05
100
- }
101
- ]
102
- message: ""
103
- invitrodb_response:
104
- summary: invitrodb_v4_3 query success
105
- value:
106
- status: "success"
107
- data: [
108
- {
109
- "chnm": "Aspirin",
110
- "assay_name": "Cell Viability Assay",
111
- "conc": 10.0,
112
- "rval": 25.8
113
- }
114
- ]
115
- message: ""
116
- '400':
117
- description: Bad Request (client-side error)
118
- content:
119
- application/json:
120
- schema:
121
- type: object
122
- properties:
123
- status:
124
- type: string
125
- default: "error"
126
- message:
127
- type: string
128
- examples:
129
- invalid_db_identifier:
130
- summary: Incorrect database identifier
131
- value:
132
- status: "error"
133
- message: "Parameter error: db_identifier only supports pubchemlite/invitrodb_v4_3"
134
- special_char_error:
135
- summary: Unescaped special characters in SQL
136
- value:
137
- status: "error"
138
- message: "SQL parsing error: pred_CCS_A2_[M+H]+ needs escaping (recommended: `pred_CCS_A2_[M+H]+` or pred_CCS_A2_\\[M+H\\]+)"
139
- format_char_conflict:
140
- summary: Python format character conflict
141
- value:
142
- status: "error"
143
- message: "Request processing failed: unsupported format character 'A' (please avoid %/A/s/d format characters in SQL)"
144
- cross_db_field:
145
- summary: Cross-database field query
146
- value:
147
- status: "error"
148
- message: "SQL syntax error: CompoundName field does not exist in invitrodb_v4_3 database (this field is only supported in pubchemlite)"
149
- '500':
150
- description: Server Error (database/server-side error)
151
- content:
152
- application/json:
153
- schema:
154
- type: object
155
- properties:
156
- status:
157
- type: string
158
- default: "error"
159
- message:
160
- type: string
161
- examples:
162
- db_connection_failed:
163
- summary: Database connection timeout
164
- value:
165
- status: "error"
166
- message: "Database connection failed: pubchemlite database connection timeout, please check database configuration"
167
- table_not_exist:
168
- summary: Table does not exist in target database
169
- value:
170
- status: "error"
171
- message: "Database execution error: assay table does not exist in pubchemlite database (this table is only supported in invitrodb_v4_3)"
172
- sql_timeout:
173
- summary: SQL query timeout
174
- value:
175
- status: "error"
176
- message: "SQL execution timeout: please add LIMIT to restrict returned rows (recommended LIMIT 100)"
177
- parameters: []
178
- components:
179
- schemas: {}
 
1
+ openapi: 3.0.1
2
+ info:
3
+ title: SQL Executor for Dual Databases
4
+ description: |
5
+ Execute read-only SQL queries on two specialized databases and return structured JSON results:
6
+ - pubchemlite: Compound basic information database (core table: pubchemlite_exposomics_20251226)
7
+ - invitrodb_v4_3: In vitro toxicity experiment database (core tables: assay, chemical, mc0, assay_component)
8
+ (Adapted for local/server Flask API, only SELECT queries supported, write/modify operations prohibited)
9
+ version: 1.0.0
10
+ servers:
11
+ - url: http://localhost:5000 ##Modify according to your local computer configuration
12
+ description: Main API Server
13
+ paths:
14
+ /execute_sql:
15
+ post:
16
+ summary: Execute SELECT query on specified database
17
+ operationId: executeSqlPost
18
+ description: |
19
+ Execute read-only SELECT queries on pubchemlite or invitrodb_v4_3 database.
20
+ Notes:
21
+ 1. Only SELECT operation is allowed (INSERT/UPDATE/DELETE/DROP are prohibited);
22
+ 2. For fields with special characters (e.g. pred_CCS_A2_[M+H]+ in pubchemlite), escape []/+ with backslash (\) or use backticks (`);
23
+ 3. Avoid Python format characters (%, A, s, d) in SQL to prevent parsing errors;
24
+ 4. Add LIMIT clause to avoid large result sets (recommended LIMIT 100).
25
+ requestBody:
26
+ required: true
27
+ content:
28
+ application/json:
29
+ schema:
30
+ type: object
31
+ properties:
32
+ db_identifier:
33
+ type: string
34
+ description: Target database identifier (case-sensitive)
35
+ enum: [pubchemlite, invitrodb_v4_3]
36
+ example: "pubchemlite"
37
+ x-validation: "Must be one of the specified enum values"
38
+ sql:
39
+ type: string
40
+ description: |
41
+ Valid MySQL SELECT query (only):
42
+ ## pubchemlite (core table: pubchemlite_exposomics_20251226)
43
+ Key fields:
44
+ - Basic info: Identifier, CompoundName, MolecularFormula, SMILES, XLogP
45
+ - Literature/Patent: PubMed_Count, Patent_Count
46
+ - Toxicity/Property: SafetyInfo, ToxicityInfo, MonoisotopicMass
47
+ - Predicted CCS: pred_CCS_A2_[M+H]+, pred_CCS_A2_[M+Na]+, pred_CCS_A2_[M-H]- (escape special chars!)
48
+
49
+ ## invitrodb_v4_3 (core tables)
50
+ - assay: aid, assay_name, organism, tissue, ncbi_taxon_id
51
+ - chemical: chid, casn, chnm (chemical name), dsstox_substance_id
52
+ - mc0: m0id, acid, spid, conc (concentration μM), rval (response value)
53
+ - assay_component: acid, assay_component_name (toxicity type)
54
+ examples:
55
+ pubchemlite_example:
56
+ summary: Query compound basic info (with escaped special field)
57
+ value: "SELECT Identifier, CompoundName, `pred_CCS_A2_[M+H]+` FROM pubchemlite_exposomics_20251226 WHERE PubMed_Count > 5 LIMIT 10"
58
+ invitrodb_example:
59
+ summary: Query human in vitro toxicity data
60
+ value: "SELECT c.chnm, a.assay_name, m.conc, m.rval FROM chemical c JOIN mc0 m ON c.dsstox_substance_id = m.dsstox_substance_id JOIN assay a ON m.aid = a.aid WHERE a.ncbi_taxon_id = 9606 LIMIT 10"
61
+ required:
62
+ - db_identifier
63
+ - sql
64
+ x-error-tips: |
65
+ 1. Missing required parameters: Ensure both db_identifier and sql are provided;
66
+ 2. Invalid db_identifier: Only pubchemlite/invitrodb_v4_3 are allowed;
67
+ 3. SQL syntax error: Check field/table names and special character escaping.
68
+ responses:
69
+ '200':
70
+ description: Query executed successfully (returns array of records)
71
+ content:
72
+ application/json:
73
+ schema:
74
+ type: object
75
+ properties:
76
+ status:
77
+ type: string
78
+ enum: [success, error]
79
+ description: Execution status
80
+ data:
81
+ type: array
82
+ items:
83
+ type: object
84
+ description: Query results (key = field name, value = field value)
85
+ additionalProperties: true
86
+ message:
87
+ type: string
88
+ description: Error message (empty if success)
89
+ examples:
90
+ pubchemlite_response:
91
+ summary: pubchemlite query success
92
+ value:
93
+ status: "success"
94
+ data: [
95
+ {
96
+ "Identifier": "CID12345",
97
+ "CompoundName": "Aspirin",
98
+ "MolecularFormula": "C9H8O4",
99
+ "pred_CCS_A2_[M+H]+": 181.05
100
+ }
101
+ ]
102
+ message: ""
103
+ invitrodb_response:
104
+ summary: invitrodb_v4_3 query success
105
+ value:
106
+ status: "success"
107
+ data: [
108
+ {
109
+ "chnm": "Aspirin",
110
+ "assay_name": "Cell Viability Assay",
111
+ "conc": 10.0,
112
+ "rval": 25.8
113
+ }
114
+ ]
115
+ message: ""
116
+ '400':
117
+ description: Bad Request (client-side error)
118
+ content:
119
+ application/json:
120
+ schema:
121
+ type: object
122
+ properties:
123
+ status:
124
+ type: string
125
+ default: "error"
126
+ message:
127
+ type: string
128
+ examples:
129
+ invalid_db_identifier:
130
+ summary: Incorrect database identifier
131
+ value:
132
+ status: "error"
133
+ message: "Parameter error: db_identifier only supports pubchemlite/invitrodb_v4_3"
134
+ special_char_error:
135
+ summary: Unescaped special characters in SQL
136
+ value:
137
+ status: "error"
138
+ message: "SQL parsing error: pred_CCS_A2_[M+H]+ needs escaping (recommended: `pred_CCS_A2_[M+H]+` or pred_CCS_A2_\\[M+H\\]+)"
139
+ format_char_conflict:
140
+ summary: Python format character conflict
141
+ value:
142
+ status: "error"
143
+ message: "Request processing failed: unsupported format character 'A' (please avoid %/A/s/d format characters in SQL)"
144
+ cross_db_field:
145
+ summary: Cross-database field query
146
+ value:
147
+ status: "error"
148
+ message: "SQL syntax error: CompoundName field does not exist in invitrodb_v4_3 database (this field is only supported in pubchemlite)"
149
+ '500':
150
+ description: Server Error (database/server-side error)
151
+ content:
152
+ application/json:
153
+ schema:
154
+ type: object
155
+ properties:
156
+ status:
157
+ type: string
158
+ default: "error"
159
+ message:
160
+ type: string
161
+ examples:
162
+ db_connection_failed:
163
+ summary: Database connection timeout
164
+ value:
165
+ status: "error"
166
+ message: "Database connection failed: pubchemlite database connection timeout, please check database configuration"
167
+ table_not_exist:
168
+ summary: Table does not exist in target database
169
+ value:
170
+ status: "error"
171
+ message: "Database execution error: assay table does not exist in pubchemlite database (this table is only supported in invitrodb_v4_3)"
172
+ sql_timeout:
173
+ summary: SQL query timeout
174
+ value:
175
+ status: "error"
176
+ message: "SQL execution timeout: please add LIMIT to restrict returned rows (recommended LIMIT 100)"
177
+ parameters: []
178
+ components:
179
+ schemas: {}