-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_evadb.py
40 lines (31 loc) · 1.02 KB
/
run_evadb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, request
from flask_cors import CORS
import evadb
app = Flask(__name__)
cors = CORS(app, resources={r"/*": {"origins": "*"}})
cursor = evadb.connect().cursor()
@app.route('/execute', methods = ['POST'])
def execute():
data = request.json['query']
res = cursor.query(data).df()
return res.to_json(orient ='records')
@app.route('/create', methods = ['POST'])
def create():
data = request.json['params']
query = """
CREATE DATABASE {name}
WITH ENGINE = '{engine}',
PARAMETERS = {{
"user": '{user}',
"password": '{password}',
"host": '{host}',
"port": '{port}',
"database": '{db}'
}};
""".format(name=data['name'], engine=data['engine'], user=data['user'], password=data['password'], host=data['host'], port=data['port'], db=data['db'])
res = cursor.query(query).df()
return res.to_json(orient ='records')
def run():
return app
if __name__ == "__main__":
app.run(debug=True)