Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 12099
1 vote
Accepted

Difference between { var } vs :var as placeholder - SQL, Postgre

Especially from a security point of view, do not use f-strings (or similar measures) for building your SQL query, you might risk SQL injections. … If I remember correctly, David talks about SQL injections around the end of week 7 lecture (looked it up: CS50 fall 2019/CS50x 2020 week 7 lecture, starting around 1:43:00). …
Blauelf's user avatar
  • 21k
6 votes
Accepted

PSET7 Movies Q9: Why is my number of rows generated different from what the assignment requi...

In other SQL dialects you could use DISTINCT ON (col1, col2) with an "ON" and a list of columns to use for the DISTINCT, but SQLite does not seem to support such thing. …
Blauelf's user avatar
  • 21k
1 vote
Accepted

I am having trouble correctly rendering bought.html Can someone help? More details below

{% for y in range(db_stock_info_num_columns_len) %} {% for x in range(db_stock_info_num_rows_len) %} <tr> {{[y]}} <th> {{database_stock_info[x][y]}} </th> </tr> {% endfor %} {% endfor %} …
Blauelf's user avatar
  • 21k
1 vote
Accepted

Getting an error in my code. Can someone help? My main question is can a select statement re...

The error message says RuntimeError: no such column: symbol [SQL: "select shares from stock_info WHERE symbol = 'AAPL' and id = 19"] That does not mean your stock_info table is empty, it is missing …
Blauelf's user avatar
  • 21k
0 votes
Accepted

Can a select return nothing without causing an error? How do I create a if condition that re...

It won't return "nothing" (None in Python), but it can return an empty result list. Like a SELECT * FROM users WHERE 0=1; The condition is always false, so it would return no rows, and with our API …
Blauelf's user avatar
  • 21k
1 vote
Accepted

Inserting transaction type into SQL database (CS50 Finance)

"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). … to sum them up in SQL later). …
Blauelf's user avatar
  • 21k
1 vote
Accepted

pset7 "index" - using SQL SUM adds a parenthesis to returned dict strings

You can use AS to rename a field, this is especially useful if you join multiple tables and return fields from several of them, or when using aggregate functions as you do here. Like "SELECT buy.stock …
Blauelf's user avatar
  • 21k
1 vote

Pset7 - Finance (register function) - creating internal server error

You are missing the ) for your db.execute statement. Count the opening and closing parentheses.
Blauelf's user avatar
  • 21k
0 votes

cs50 pset7 finance always get an error in valid buy execution;;;;;

Would have been incredibly helpful to have the relevant line number in your code, as presented in complete stack trace. This way, I can only guess what caused it. Remember that SELECT returns a list …
Blauelf's user avatar
  • 21k
0 votes

pset7 finance register sql

(I did the latter in my early SQL code, and it's dangerous stuff allowing for SQL injections, ask Bobby Tables) …
Blauelf's user avatar
  • 21k
0 votes

Final project SQL Error: execute() takes 2 positional arguments but 3 were given

Not understanding how your maths relate to your code, but shouldn't it be id=convert_from and id=convert_to? And I'd expect something like conversion_result = float(amount) * row_1[0]["BUM"] * row_2[ …
Blauelf's user avatar
  • 21k
0 votes

PS7: Please give me a hint on flask loop usage

As I've yet to do this one, I haven't read the task, but this looks wrong: db.execute("UPDATE portfolio SET price_current = price_current WHERE stock = :stock", stock = symbol) Maybe you meant db. …
Blauelf's user avatar
  • 21k