Hot answers tagged

4

All very good questions. You're thinking about what redundancies can be eliminated. But then, you need to think further. What's more important, conserving storage or making queries more efficient? First, look at the case of the zip code table. Zip codes are essentially unique and constant. Info related to cities and zip codes rarely change. Linking back to ...


1

I was typing that answer while you were posting. In short, you created a primary index on user id. The effect of this is to tell the table that only one entry with that ID is allowed. You could still add transactions for other id's, but only one each. An index is still useful though. If you set up your column and index to non-unique and non-primary, then ...


1

Try checking your index+ link on the Structure view. I deleted all my unique and primary keys, as well as any links to other tables. This solved the problem..thanks to Kareem .. and, I apologise for submitting a comment as an answer earlier. Frustrated newbie here, not paying attention!


1

Problems are here transaction_type = buy and here transaction_type = sell. buy and sell are functions, which is an invalid type to insert into the database. Perhaps you meant the string literals "buy" and "sell".


1

You might consider sending the purchases list to the template and using a jinja for loop to iterate over the members to create the table rows. So instead of sending each variable separately to the html like this: return render_template("history.html", stock=stock, boughtsold=boughtsold, price=price, shares=shares, time=time, userid=userid) it might be ...


1

That's happening in the first line of code you showed. The db.execute is missing a named argument, something like db.execute("... WHERE user_id = :user_id", user_id=session["user_id"]) ^^^^^^^ = ^^^^^^^ these two are same The rest of the code does not make too much sense to me, as you would render the template for a single ...


1

"transaction" is a reserved word in SQL, meant for SQL-style transactions (executing a number of statements and having them applied all at once or rolled back). You could rename your field, put it in quotation marks 'transaction' in the SQL statement, or remove it and use positive share numbers for buying, and negative for selling (this can be useful if you ...


Only top voted, non community-wiki answers of a minimum length are eligible