Set up database for text to SQL
()
| 10 | |
| 11 | @bp.route('/setup', methods=['POST']) |
| 12 | def 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']) |
nothing calls this directly
no outgoing calls
no test coverage detected