Skip to content

Commit

Permalink
Update python_api/db.py to fix error when running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlee7128 committed Oct 30, 2024
1 parent 26fea70 commit f6f5533
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python_api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def create_trial( model_id, experiment_id, cur, conn,source_id="",completed_at=N

def create_trial_inputs(trial_id, inputs, cur, conn):
cur.execute("SELECT MAX(id) as id FROM trial_inputs")
max_id = int(cur.fetchone()["id"])
try:
max_id = int(cur.fetchone()["id"])
except:
max_id = 0
cur.execute("INSERT INTO trial_inputs (id,created_at,updated_at,trial_id, url) VALUES (%s,%s,%s,%s, %s)", (max_id+1, datetime.now(), datetime.now(),trial_id, json.dumps(inputs)))
conn.commit()

Expand Down

0 comments on commit f6f5533

Please sign in to comment.