我正在尝试使用以下代码
mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
app.config['MYSQL_DATABASE_DB'] = 'compData'
app.config['MYSQL_DATABASE_HOST'] = '0.0.0.0'
mysql.init_app(app)
@app.route("/Authenticate")
def Authenticate():
cursor = mysql.connect().cursor()
cursor.execute("SELECT * from abclimit 5")
pro_info = pd.DataFrame(data=cursor.fetchall(), index=None,columns=[i[0] for i in cursor.description])
return Response(json.dumps(pro_info), mimetype='application/json')
if __name__ == "__main__":
app.run()
但是给我错误
File "pathe\frame.py", line 303, in __init__
raise PandasError('DataFrame constructor not properly called!')
pandas.core.common.PandasError: DataFrame constructor not properly called!
我想从sql查询结果
创建pandas DF