0

The code I've written for the parameter checks all works fine, and on clicking the buy button everything seems to work... but then nothing gets added to my database! I've combed through the SQL query again and again. I'm so sure the syntax is correct, and I'm not getting any error messages... Can anyone spot where I'm going wrong?

# record purchase
purchase = db.execute("INSERT INTO transactions (user_id, symbol, name, shares, price, total) VALUES (:user_id, :symbol, :name, :shares, :price, :total)",
    user_id=session["user_id"], symbol=result["symbol"], name=result["name"], shares="shares", price=result["price"], total="total")

A lengthier snippet of my code is here: https://gist.github.com/4b64b3d28aa19568d4bfbb0039cc47d8

1 Answer 1

0

Assuming transactions.total is a numeric field, this total="total" would be problematic since "total" is a string literal.

1
  • That's precisely what it was... also, I had set the date_time field to Not Null without assigning its default value... Wow, always such a facepalm with hindsight... Thank you so, so much for your help. Mar 17, 2017 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .