0

I get an error in the request to /login:

Exception raised in application: RuntimeError: no such table: stock [SQL: 'SELECT symbol, SUM(shares) FROM stock WHERE userid = 18 GROUP BY symbol'] (Background on this error at: http://sqlalche.me/e/e3q8)

This is the code for the index:

def index():

variableXXX = db.execute("SELECT symbol, SUM(shares) FROM Stock WHERE userid = :userid GROUP BY symbol", userid=session["user_id"])

Many thanks!

1 Answer 1

0

The error is quite literal and unambiguous. There is not table named 'stock' in the database to which flask is connected. The two main causes of this type of failure:

  1. Simple misspelling. Verify the table is indeed named stock. You can use the .tables command in sqlite3 or doublecheck the spelling in phpLiteAdmin.
  2. Two databases named finance.db. When you run sqlite3 finance.db (or command line phpliteadmin finance.db) it will create a database named finance.db if one is not found. So if you run either in the "wrong" directory, that's where the database with the stock table is.
1
  • Thank you for this, I had a similar error because I didn't add "s" to "transaction". You saved me from a month of frustration. God bless
    – Iberrie
    Commented Dec 1, 2018 at 9:41

You must log in to answer this question.

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