Questions tagged [db.execute]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

issue with my “Buy” code in finance problem set

There is a syntax error when I try to insert the buy information into my trade table. Here is my code. The issue is at the long db.execute line. Any guidance would be great. Thanks. def buy(): &...
0
votes
1answer
183 views

Getting an error in my code. Can someone help? My main question is can a select statement return an empty list without having an error?

Here is the code @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" if request.method == "POST": stock = request.form.get("symbol") ...
0
votes
1answer
30 views

Can a select return nothing without causing an error? How do I create a if condition that returns True if the database is empty?

I posted my code in another post I have made a lot of revisions. Kind of irrelevant but just thought I should mention it if someone goes through my last post. I have a select statement. Lets say my ...
0
votes
1answer
39 views

in the register function, I need help understanding why db insert works to get id for session[“user_id”]

username_form = request.form.get("username") id_db = db.execute("SELECT id from users where username=username_form") I understand why session["user_id"] = id_db[0]["id"]doesn't work to get the id. ...
0
votes
1answer
28 views

How do I select a specific part of the database

id | username | hash | cash 1 bill efgeil 10000 2 tim fgrgol 10000 3 jim h6ju8k 10000 why does username_list_check[y]["username"] need the "["username"]"? ...
0
votes
1answer
238 views

Finance Pset, SQL DB, db.execute troubles

Implementing the Buy route and running into difficulty with updating the DB...I've tested the rest of my code which all works, but whenever I use the two db.execute lines at the end of the code, I get ...
0
votes
1answer
43 views

Rollback support in SQL library (pset7)

I need to be able to "rollback" from a "transaction" to the DB in case a sequence of db queries don't all succeed. I could not find any documentation regarding this ability using the SQL library ...
0
votes
1answer
184 views

pset7 I can't use usd() and have a problem with datetime method

1- pset7 I can't use usd() because I still need the values(int) to select the number for calculation 2- I used datetime.datetime.now()and it gives me just date without the time. anyone can help me :) ...
0
votes
1answer
345 views

pset8 search function not working like supposed to

I'm trying to implement search in pset8 so that it can narrow down searches based on whether a comma followed by a state name or symbol is included. For example, the standard search would output many ...
1
vote
1answer
36 views

Passing SQL values into arrays

I'm designing a budgeting website for the final project. One of the features that I want to implement is to be able to track how much money you've spent for each item category. The SQL command that I'...
1
vote
1answer
440 views

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

I'm having issues with buy. Initially, I was getting a RuntimeError: no such column: user_id At the time, I had the first code as below. After making changes, I now get RuntimeError: Bind parameter '...
0
votes
1answer
178 views

Pset7 Can't manage to get the result of a SUM() using db.execute

I'm trying to understand a function that could help me in the SELL part of the pset7, but so far, I'm failing... I want to select from my database every shares own by the user, grouping them by name ...