-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
22 lines (19 loc) · 660 Bytes
/
Copy pathdb.py
File metadata and controls
22 lines (19 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import jsonify
import pymysql
def query(querystr,return_json=True):
connection=pymysql.connect(host='skillup-team-11.cxgok3weok8n.ap-south-1.rds.amazonaws.com',
user='admin',
password='coscskillup',
db='restapi',
cursorclass=pymysql.cursors.DictCursor)
connection.begin()
cursor=connection.cursor()
cursor.execute(querystr)
result=cursor.fetchall()
connection.commit()
cursor.close()
connection.close()
if return_json:
return jsonify(result)
else:
return result