我想将事件json数据从 flask-socketio 传递到flask-SQLalchemy
下面是我的代码:
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
from flask_sqlalchemy import SQLAlchemy
@socketio.on( 'my event' )
def handle_my_custom_event( json ):
#HOW TO PASS THE VALUE from this event to my database
#AM i using import json or flask-json and how? any reference
# usern = History(username=json.user_name)
# messg = History(message=json.messg)
# db.session.add(usern)
# db.session.add(messg)
# db.session.commit()
print( 'recived my event: ' + str( json ) )
socketio.emit( 'my response', json, callback=messageRecived )
这不起作用。我是python烧瓶的新手。请提供任何参考或解释