Hot answers tagged

3 votes
Accepted

pset7 - how to get current id?

From the C$50Finance spec Hints re the execute method: 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 ...
DinoCoderSaurus's user avatar
3 votes

TypeError: 'NoneType' object is not subscriptable in PSET9, but working manually

I noticed that the issue lies in the line where I insert the stock symbol into the "stocks" table in the buy function. The problem is that I am passing stock["name"] instead of ...
Chris's user avatar
  • 31
2 votes
Accepted

pset7 buy - ON DUPLICATE KEY syntax question

'ON DUPLICATE KEY UPDATE' is MySQL syntax. But is this really what you need to do? Remember from the spec: Add one or more new tables to finance.db via which to keep track of the purchase. Store ...
DinoCoderSaurus's user avatar
2 votes
Accepted

Pset7 buy - RuntimeError sqlite3.OperationalError near transaction

transaction is a sqlite reserved word. You'll need to escape the column name with quotes (eg 'transaction') or create the table again and rename the column.
DinoCoderSaurus's user avatar
2 votes
Accepted

Struggle passing values from Python to HTML via Flask

From the flask doc (Rendering Templates): To render a template you can use the render_template() method. All you have to do is provide the name of the template and the variables you want to pass ...
DinoCoderSaurus's user avatar
2 votes
Accepted

pset7 question about tables in buy

Ok, I may be wrong about this and I can delete my answer so it stays unanswered if I am. I think the spec is a little murky referenced by Dino on the question linked above. Dino interpreted it to ...
dumbitdownjr's user avatar
2 votes
Accepted

Pset7 buy portfolio values are null

I can see a couple of things that you may consider changing and also most of your code is correct,so just few things to add on! The code where you are inserting values after checking that cash > ...
sk.76's user avatar
  • 312
2 votes
Accepted

What's the error?-PSET7/buy

According to the error message, this is an Operational Error. Your error message says: (Background on this error at: http://sqlalche.me/e/e3q8) That link point to a paragraph describing the ...
Peter Pesch's user avatar
2 votes
Accepted

Pset 7 buy - help!!

it seems like when I select the cash value from my SQL table, it is producing a list Quite true. From the Hints section of the spec: If str is a SELECT, then execute returns a list of zero or ...
DinoCoderSaurus's user avatar
2 votes
Accepted

pset7 buy typeError can't multiply

I think the line if price * shares > cash: might be problematic on multiple stages. Here, price would be the float, and shares the sequence. shares is probably a string and needs conversion to ...
Blauelf's user avatar
  • 20.9k
2 votes

Pset7 buy portfolio values are null

buy should not contain a session["user_id"] =, you would overwrite the user id of the current session that way. The only place for that is login. That might be what causes the error message, you ...
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

PSET9 Finance: Check50 says Buy doesn't handle fractional/invalid shares, but when I try these things my page does reject them. Why check50 no like?

So my first question is, where does it come from? It's either bootstrap or the browser. check50 does not use the front end to make the API calls. Therefore any limits put on the html, while GREAT for ...
DinoCoderSaurus's user avatar
2 votes

CS50 Finance (week 9 problem set) Check 50 Fails despite program working fine, please help

Solved it thanks to some advice from CS50 discord, When you use the lookup function it returns: "name" "price" "symbol" When I stored a transaction in my database is was ...
Seth 's user avatar
  • 31
1 vote

pset7 buy sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near ",": syntax error [SQL: "SELECT * FROM portfolio WHERE user_id= 16, sy

Ok, I found mistake - after WHERE if there is few conditions there have to be an AND between them
Maciej Ś's user avatar
1 vote

CS50 pset7 buy, Runtime Error: Too many statements

Just a small typo here :name;. Easy to miss, hard to find. (; is the sql delimiter, so "it" thinks you are trying to run 2 sqls).
DinoCoderSaurus's user avatar
1 vote

Finance: Buy AttributeError: 'TypeError' object has no attribute 'name'

Look in the flask log again. For some reason any error from flask is always followed by the one from errorhandler that you show here, which starts with ERROR:werkzeug:Error on request:. Go backwards ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 finance portfolio table won't update with buy function

Have you looked at all of the error or other messages returned? The portfolio table has 6 fields, all of which are NOT NULL and don't appear to have defaults, but the insert and update sql code only ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Portfolio not updating in SQLite, Problem Set 7, Buy

The error is caused by the SQL command to INSERT failing because the table 'portfolio' doesn't exist. Create the table and then it should work. :)
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

cs50 pset7 buy syntax error

I would expect you to have an autoincrementing id field that is the primary key (so each transaction has an id) and then a user_id field that holds the user_id for the transaction (that is not unique)....
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

pset7 buy function stopped working... not inserting to portfolio

I have a number of questions that may answer your issue. Does it still work if you create a new user and "buy" a new stock? Does it work for an old user and a new stock that nobody has bought? Does ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

can someone please help me with why I am getting internal server error after I enter the symbol and no. and click on buy ?pset7

From your error message: line 143, in buy name=info["name"], ... \ KeyError: 'name' The issue appears to be the 'KeyError' 'name': name=info["name"] Does your dictionary 'info' have a key called ...
PrawnBallNightmare's user avatar
1 vote
Accepted

Pset7 - buy updates shares in portfolio but not cash in users

The problem is here db.execute=("UPDATE users SET cash= cash -:purchase WHERE id=:id", id = session["user_id"]). You are binding :purchase but you never set it to anything.
DinoCoderSaurus's user avatar
1 vote
Accepted

`RuntimeError: no such column: user_id` pset7 [buy]

I solved it using this link Challenge inserting into database from buy() as a resource. The problem was with the placement of my quotes I changed db.execute("INSERT INTO transactions (user_id, ...
Salamit's user avatar
  • 231
1 vote
Accepted

Problem Set 7 - Buy - RuntimeError

The error from this sql INSERT INTO users ('transaction') VALUES(:cash) (quotes or not) is because there is no column named transaction in the users table. Now is the perfect time to add a table for ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset7: How to get "Bought!" Alert in /Index when re-directing from /Buy (I tried IF condition, but failed)

@dinocodersaurus's link :) flash ("Bought") return redirect(url_for("index"))
nvs0000's user avatar
  • 179
1 vote
Accepted

Challenge inserting into database from buy()

I vote sophisticated :) The problem is :transaction_date, or lack thereof.
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 buy SQL syntax error

Here is the documentation for sqlite SELECT. The '.' represents the delimiter in a schema-name.table-name.column-name result-column expression.
DinoCoderSaurus's user avatar
1 vote

pset7 buy SQL syntax error

Enclose the column name within square brackets . i.e [users.id] Just a suggestion, avoid using '.' character in sql attribute names.
Vikrant Pradhan's user avatar
1 vote
Accepted

Pset7. I don't know how to handle POST request of 'finance-buy'. Need help

And I can't see '666666' in my command console. Assuming you mean the browser console, that is not where you should be looking. Since application.py is running on the server, any print messages will ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset7 Buy - data re-submitted when I Reload page

You need to use the Post/Redirect/Get design pattern. By doing return render_template("buydisplay.html", rows = rows, cash = cashi), you are "staying" in the buy form with method "POST", so a ...
DinoCoderSaurus's user avatar

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