Spaces:
Sleeping
Sleeping
Commit
·
ff320d6
1
Parent(s):
9857021
Add PostgreSQL connection and fetch API configurations in validate_api_call
Browse files- api_validator.py +17 -2
api_validator.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
import apiCall
|
| 2 |
import json
|
| 3 |
-
import os
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
import hashlib
|
| 6 |
-
|
| 7 |
|
| 8 |
def validate_api_call(
|
| 9 |
mcp_api_key,
|
|
@@ -235,6 +234,22 @@ def validate_api_call(
|
|
| 235 |
# Store configuration
|
| 236 |
# TODO: Implement database
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
# Return success response
|
| 239 |
return {
|
| 240 |
"success": True,
|
|
|
|
| 1 |
import apiCall
|
| 2 |
import json
|
|
|
|
| 3 |
from datetime import datetime, timedelta
|
| 4 |
import hashlib
|
| 5 |
+
import psycopg2
|
| 6 |
|
| 7 |
def validate_api_call(
|
| 8 |
mcp_api_key,
|
|
|
|
| 234 |
# Store configuration
|
| 235 |
# TODO: Implement database
|
| 236 |
|
| 237 |
+
conn = psycopg2.connect(
|
| 238 |
+
database = "testdb",
|
| 239 |
+
user = "postgres",
|
| 240 |
+
host= 'localhost',
|
| 241 |
+
port = 5432
|
| 242 |
+
)
|
| 243 |
+
cur = conn.cursor()
|
| 244 |
+
cur.execute('select * from api_configurations')
|
| 245 |
+
|
| 246 |
+
rows = cur.fetchall()
|
| 247 |
+
conn.commit()
|
| 248 |
+
conn.close()
|
| 249 |
+
for row in rows:
|
| 250 |
+
print(row)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
# Return success response
|
| 254 |
return {
|
| 255 |
"success": True,
|