I am passing from my local machine, a person id and person name to an ubuntu server. then this information will be read and passed to the database. I am using the below code, but somehow I am not able to get it done. I am new to all these, so not sure what I am missing
@app.route("/personInformation", methods=['POST'])
def parsingData():
data = request.get_json(force=True)
personID = data['person_id']
personName = data['person_name']
import pandas as pd
import sqlalchemy as sql
import sqlalchemy.orm as orm
db=sql.create_engine(connectionString)
metadata = sql.schema.MetaData(bind=db,reflect=True)
table = sql.Table('patient_all_info', metadata, autoload=True)
class Row(object):
pass
rowmapper = orm.Mapper(Row,table)
Sess = orm.sessionmaker(bind = db)
session = Sess()
row1 = Row()
row1.person_id = personID
row1.person_name = personName
session.add(row1)
session.commit()
return "sent, no error"
except:, which is hiding the error, and the rerun your code and post the error with the traceback.db=sql.create_engine(connectionString). So it is not "very wrong" at all. But still, if you're using Flask-SQLAlchemy, do follow its tutorials :). The link you provided handles mapping the "old way" among other things, instead of using Declarative. Flask-SQLAlchemy also provides integration to Flask request life cycle out of the box.