Web Dev with Python Flask project

With reference to Jovian Project- WebDev with Python Flask.
The below code doesnt seem to work and i have tried to search for a solution but in-vain.

connstring=conn.execute(text(“select * from jobs where id=:val”),val=id)

i get the below error.
TypeError: Connection.execute() got an unexpected keyword argument ‘val’

Can you please suggest.

Hi @ tsr71a
I had the same error from Jovian Project-
This is the fixed code and working-

def load_job_from_db(id):
  with engine.connect() as conn:
    result = conn.execute(
      text(f"SELECT * FROM jobs WHERE id = :val"),
      {"val": id}
    rows = result.mappings().all()
    if len(rows) == 0:
      return None
      return dict(rows[0])
1 Like

thank you so much it actually helps :slight_smile:

Thank you! This helped me too!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.