I need to know how to represent the date and time of purchase correctly in my table for storing who bought what at what price and when (as per the specs for buy). I tried to use datetime.datetime.now(), but for some reason I kept getting an error saying that the interpreter doesn't know how to display the value as a quoted literal. Is there a way I can tell it how to display the return value of that function? This is the code I have for entering data into that table: db.execute("INSERT INTO transactions(stock_name, stock_price, user_id, time, no_of_shares) VALUES(:stock_name, :stock_price, :user_id, :time, :no_of_shares)", stock_name=stock["name"], stock_price=stock["price"], user_id=session["user_id"], time=time.time(), no_of_shares=user_input_shares). (As you can see, I used time.time() instead - but the value this puts into the table is one I don't understand (1489347879.51058).


How about making your time column in your table have a default value of CURRENT_TIMESTAMP so it gets filled in automatically. That way, each time you insert into transactions, the value will be put in (and you don't need to explicitly list it in your query).

You must log in to answer this question.

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