0

I am currently working on my sell function of finance and I need to make shares = -shares in my history table to show the selling of the stock. However, I keep getting an error:

int() argument must be a string, a bytes-like object or a number,not 'list'

I currently have the shares selected:

shares = db.execute("SELECT shares FROM portfolio \
            WHERE id=:id AND symbol=:symbol", \
            id= session["user_id"], \
            symbol = stock["symbol"])

then later...

db.execute("INSERT INTO history (symbol, shares, price, id) \
            VALUES(:symbol, :shares, :price, :id)", \
            symbol = stock["symbol"], \
            shares = -int(shares), \
            price = stock["price"], \
            id= session["user_id"])

I also made sure that in the SQL tables, shares are put as type int.

Can someone please let me know how to do make shares an integer? Thanks!

1 Answer 1

2

From the Hints section of the spec:

If str is a SELECT, then execute returns a list of zero or more dict objects, inside of which are keys and values representing a table’s fields and cells, respectively.

You could review the login function to see how the results of the SELECT query (rows) are accessed.

You must log in to answer this question.

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