Qianhui19 commited on
Commit
1c35134
·
verified ·
1 Parent(s): e4311aa

Update step1_pubchemlite_invitrodb_to_dify_en.py

Browse files
step1_pubchemlite_invitrodb_to_dify_en.py CHANGED
@@ -10,10 +10,10 @@ app = Flask(__name__)
10
  # Configure connection information for two databases (please modify username/password/address according to actual environment)
11
  DB_CONFIGS = {
12
  "pubchemlite": {
13
- "uri": "mysql+pymysql://sql_user:SQLUSER@localhost:3306/pubchemlite"
14
  },
15
  "invitrodb_v4_3": {
16
- "uri": "mysql+pymysql://sql_user:SQLUSER@localhost:3306/invitrodb_v4_3" # Please confirm database name and password
17
  }
18
  }
19
 
@@ -95,10 +95,10 @@ def execute_sql():
95
  except SQLAlchemyError as e:
96
  error_msg = str(e)
97
  # Refine error messages to fit the two database scenarios
98
- if "pubchemlite_ccs" in error_msg and db_identifier == "invitrodb_v4_3":
99
- error_msg = f"pubchemlite_ccs table does not exist in invitrodb_v4_3 database (this table is only supported in pubchemlite): {error_msg}"
100
  elif "CompoundName" in error_msg and db_identifier == "invitrodb_v4_3":
101
- error_msg = f"CompoundName field does not exist in invitrodb_v4_3 database (this field is only supported in pubchemlite_ccs table of pubchemlite): {error_msg}"
102
  elif "assay" in error_msg and db_identifier == "pubchemlite":
103
  error_msg = f"assay table does not exist in pubchemlite database (this table is only supported in invitrodb_v4_3): {error_msg}"
104
  return jsonify({
@@ -131,7 +131,7 @@ curl -X POST http://127.0.0.1:5000/execute_sql \\
131
  -H "Content-Type: application/json" \\
132
  -d '{
133
  "db_identifier": "pubchemlite",
134
- "sql": "SELECT Identifier, CompoundName, MolecularFormula FROM pubchemlite_ccs WHERE PubMed_Count > 5 LIMIT 10"
135
  }'
136
  </pre>
137
  <p>Example 2 (query invitrodb_v4_3):</p>
 
10
  # Configure connection information for two databases (please modify username/password/address according to actual environment)
11
  DB_CONFIGS = {
12
  "pubchemlite": {
13
+ "uri": "mysql+pymysql://api_reader:Api_Reader2024!Secure@localhost:3306/pubchemlite"
14
  },
15
  "invitrodb_v4_3": {
16
+ "uri": "mysql+pymysql://api_reader:Api_Reader2024!Secure@localhost:3306/invitrodb_v4_3"
17
  }
18
  }
19
 
 
95
  except SQLAlchemyError as e:
96
  error_msg = str(e)
97
  # Refine error messages to fit the two database scenarios
98
+ if "pubchemlite_exposomics_20251226" in error_msg and db_identifier == "invitrodb_v4_3":
99
+ error_msg = f"pubchemlite_exposomics_20251226 table does not exist in invitrodb_v4_3 database (this table is only supported in pubchemlite): {error_msg}"
100
  elif "CompoundName" in error_msg and db_identifier == "invitrodb_v4_3":
101
+ error_msg = f"CompoundName field does not exist in invitrodb_v4_3 database (this field is only supported in pubchemlite_exposomics_20251226 table of pubchemlite): {error_msg}"
102
  elif "assay" in error_msg and db_identifier == "pubchemlite":
103
  error_msg = f"assay table does not exist in pubchemlite database (this table is only supported in invitrodb_v4_3): {error_msg}"
104
  return jsonify({
 
131
  -H "Content-Type: application/json" \\
132
  -d '{
133
  "db_identifier": "pubchemlite",
134
+ "sql": "SELECT Identifier, CompoundName, MolecularFormula FROM pubchemlite_exposomics_20251226 WHERE PubMed_Count > 5 LIMIT 10"
135
  }'
136
  </pre>
137
  <p>Example 2 (query invitrodb_v4_3):</p>