Reputation: 23
def add_application_to_db(job_id, data):
with engine.connect() as conn:
sql = text(
"INSERT INTO application(id,job_id,fullname,email,linkedin,education,experience,resumeurl) VALUES (:job_id,:fullname,:email,:linkedin,:education,:experience,:resumeurl)"
)
conn.execute(
job_id=job_id,
fullname=data["fullname"],
email=data["email"],
linkedin=data["linkedin"],
education=data["education"],
experience=data["experience"],
resumeurl=data["resumeurl"],
)
I am learning flask and using MySQL and sqlalchemy.I am trying to store info from user into the data base (table name = application) I got following error
TypeError: Connection.execute() got an unexpected keyword argument 'job_id'
Upvotes: 2
Views: 1255
Reputation: 7123
If you are using SQLAlchemy 2.0 then you have to send the parameters as a dict instead of what you are trying now.
def add_application_to_db(job_id, data):
row = {
"job_id": job_id,
"fullname": data["fullname"],
"email": data["email"],
"linkedin": data["linkedin"],
"education": data["education"],
"experience": data["experience"],
"resumeurl": data["resumeurl"],
}
with engine.connect() as conn:
sql = text(
"INSERT INTO application(id,job_id,fullname,email,linkedin,education,experience,resumeurl) VALUES (:job_id,:fullname,:email,:linkedin,:education,:experience,:resumeurl)"
)
conn.execute(sql, row)
conn.commit()
Upvotes: 1