MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / setup_db

Function setup_db

byod/api/app/setup/routes.py:12–27  ·  view source on GitHub ↗

Set up database for text to SQL

()

Source from the content-addressed store, hash-verified

10
11@bp.route('/setup', methods=['POST'])
12def setup_db():
13 """
14 Set up database for text to SQL
15 """
16 request_body = request.get_json()
17 db_credentials = {}
18 db_credentials["address"] = request_body.get("address")
19 db_credentials["database"] = request_body.get("database")
20 db_credentials["username"] = request_body.get("username")
21 db_credentials["password"] = request_body.get("password")
22 db_credentials["port"] = request_body.get("port", 5432)
23
24 for key, value in db_credentials.items():
25 if not value:
26 error_msg = f"`{key}` is missing from request body"
27 return make_response(jsonify({"error": error_msg}), 400)
28
29
30@bp.route('/tables', methods=['GET'])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected