Questions tagged [sqlite]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
380 views

2017 pset8 mashup: Slow search - how to improve search performance?

I have successfully implemented search in application.py. Though ss I was testing through the app, I noticed that every search was really slow. It's turns out that every search request was from 63KB ...
1
vote
1answer
414 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 '...
1
vote
1answer
465 views

Challenge inserting into database from buy()

I'm have a challenge inserting into the database when I buy shares. I've made life a little complicated (or sophisticated!) because I decided to insert a separate step in the buying process: I start ...
1
vote
1answer
45 views

Problem set 7 insert statement fails - RuntimeError: 'str' object has no attribute 'key'

I searched through the cs50, but found no solutions for my problem: passwrd = pwd_context.encrypt(request.form.get("password")) db.execute("INSERT INTO users (username, hash, cash) VALUES (:...
1
vote
2answers
1k views

Set foreign key in phpLiteAdmin

Does anyone know how to set a foreign key using the phpLiteAdmin interface? The docs for this application are lacking, and the recommended syntax for adding a column using SQLite does not appear to ...
1
vote
1answer
807 views

roster.py not getting output

import sys import cs50 # checking argv (that there's one and it's a csv) if (len(sys.argv) != 2): sys.exit("Usage: roster.py house_name") housename = sys.argv[1] #print(house_name) #open(f"...
0
votes
1answer
480 views

How to test pset7 queries in the terminal window?

I am trying to test the queries I've saved in files i.e. 1.sql, 2.sql,.... But I can't able to test them in the terminal window. The command given in the instruction is not showing any results. ...
0
votes
2answers
353 views

Pset 7 - create table (with foreign key) from command-line

For pset7 - finance I am trying to create a new table to keep track of buy transactions. Since I want this table to have a foreign key (referencing the 'id' in the 'users' table) and I understood that ...
0
votes
2answers
75 views

CS50 Pset7: Final Questions before Wrap-Up

I am finally done with implementing my stock-trading website. Anyhow, I have some last questions before wrapping up and hope that someone can help me out to make sure I understand everything in this ...
0
votes
1answer
1k views

Pset7 buy - RuntimeError sqlite3.OperationalError near transaction

I have been working on pset7, and I have been getting this error when trying to buy via the html form: RuntimeError: (sqlite3.OperationalError) near "transaction": syntax error [SQL: "INSERT INTO ...
0
votes
1answer
50 views

How to use multiple “WHERE” while updating table in sqlite

In sqlite 3 I want to use two "WHERE" statements, here is my code right now "db.execute("UPDATE portfolio SET shares = :shares WHERE id = :ide",shares = symb[0]["shares"] - number,ide = ide)" I want ...
0
votes
1answer
29 views

Runtime Error Unsupported Value in pset9 Finance

I'm doing Pset09 "Finance" and I have been stuck in the "index" function for quite a while. I tried to use the already existing "trans" table but I am getting an error. ...
0
votes
1answer
27 views

Final Project: Problem to UPDATE table (Flask and SQLite) - RuntimeError (“unsupported value: {}”.format(value))

I'm working on a project tracking web app, in which users can create and categorise their own projects. There are more options, but a project can mainly be categorised as active or paid/finished. Any ...
0
votes
1answer
245 views

Pset8 Finance problems with SQLite inserting into a table

Inserting into a table in finance.db fails. I'm able to run the sqlite3 command via cli without errors and populate the table with the debugging snippet command: INSERT INTO history (date, symbol, ...
0
votes
1answer
325 views

Finance PSET8: Error: execute() takes 2 positional arguments but 3 were given

While implementing "Register" part in PSET8, I ran into the following problem - the code below returns: "TypeError: execute() takes 2 positional arguments but 3 were given". username = request.form....
0
votes
1answer
111 views

pset7 finance insert new row

I'm trying to add a row into my finance db using the code below (a few versions), but keeping getting an error saying I'm passing in too many variables to the execute() function. Any direction here ...
0
votes
1answer
709 views

How to insert data from a txt file to specific SQLite table column

I am trying to make the search function in mashup more versatile by creating a new column in my SQLite places table called full_location where it will hold the postal_code, place_name, and admin_name1 ...
0
votes
1answer
105 views

db.execute() executing only single time

When I enter amount, name, expinc in my html form it works for the first time, i.e. the entered data goes into database tables for the first time but whenever I try to enter data again it doesn't ...
0
votes
1answer
615 views

Finance: Update SQL Data: db.execute

Trying to add functionality to modify number of shares. This won't work: num_sell = request.form["num_sell"] db.execute("UPDATE purchases SET shares=num_sell WHERE order_num=1") "RuntimeError: (...
0
votes
1answer
299 views

How to represent current date and time of purchase in table

I need to know how to represent the date and time of purchase correctly in my table for storing who bought what at what price and when (as per the specs for buy). I tried to use datetime.datetime.now(...
0
votes
0answers
37 views

Pset9 Finance| “Index table” doesn't display all the companies

I'm doing pset9 "Finance" and I've designed the two tables in the database, one with purchases and the other with transactions. Now when I render the index page, the shares of only one ...
0
votes
1answer
32 views

Can't update shopping cart for more than one item, works fine for a single item, otherwise only the first one gets updated

I am trying to update the quantity of the products in the shopping cart by changing the number in the dropdown. If the cart has two or more items then only the first one works and the qty doesn't ...
0
votes
0answers
60 views

Final Project - Get sql to work html, python and flask

On my website for my final project I am able to enter the user info on the website, but the information is not being inserted into the sql table. I feel that I am not understanding something very ...
0
votes
1answer
22 views

Retrieving image from SQLite, “Invalid or Unsupported Image Format”

I am getting an Invalid or Unsupported Image Format when I open an image stored and retrieved in SQLite. When I input the convertToBinaryData file into the writeTofile function then the photo is ...
0
votes
0answers
114 views

pset7/houses: db.execute(“INSERT”) fails to export data to students.db

I am using pandas to read in the csv file, since I'm familiar with dataframes from R. But I think that may not be the issue here, which is that db.execute fails to export data to students.db. The code,...
0
votes
1answer
25 views

problem with nesting sql queries in flask (final project)

I've been trying to only insert new ids if they weren't inserted before in my database but the problem I've been having is that I couldn't get the nested queries to work in python flask. Whatever I do ...
0
votes
1answer
166 views

pset7 Q7: How many actors are named “Meryl”?

I am at a complete loss for something that should be very simple to find in SQLite. In the IMDB database, I have to find how many actors have the name 'Meryl', I have tried select name, count(name) ...
0
votes
1answer
254 views

Pset 7 Movies - 13.sql “Error When Executing Query - Too Many Statements at Once”

I'm working on Pset 7 "Movies" and check50 shows an error for 13.sql (list of Kevin Bacon's co-stars) when I submit my code despite running successfully in the IDE. The exact error message is Error ...
0
votes
2answers
549 views

Error Building SQLite Query Programmatically: TypeError: execute() takes 2 positional arguments but 3 were given

I'm trying to build a sqlite query programmatically by building a string that I pass to db.execute. query = "SELECT * FROM places WHERE postal_code LIKE :q" result = db.execute(query, q=q) This ...
0
votes
1answer
136 views

Importing to sqlite for final project

I'm having problems importing a file into an sqlite database for my final project. I have a .csv file which I want to import. I've created the table using the phplite GUI, with 14 fields (columns). ...
0
votes
0answers
22 views

CS50's PHPLIteAdmin [duplicate]

I am currently working on my final project, and I need to create a database which contains a table with a FOREIGN KEY field. Unfortunately, I've constantly been getting errors. Upon Googling them, I ...
0
votes
1answer
521 views

sqlite multiplying two columns

I'm trying to have sqlite automatically do the calculation below for each column. I used the following line but not getting the intended result[see picture] Any help is appreciated. SELECT ...
0
votes
1answer
151 views

RunTimeError in buy() c$50 finance

why I get this error RuntimeError: (sqlite3.OperationalError) near "'$59.31'": syntax error [SQL: "INSERT INTO portfolio (id, symbol, shares, price) VALUES(2, 'A', 1, '$59.31'"] here is my code: @...
0
votes
0answers
99 views

Pset8 no such column: postal_code

I am trying to perform simple search in mashup.db database db.execute( "SELECT * FROM places WHERE postal_code = :q",q=request.args.get("q")) However I am getting RuntimeError: (sqlite3....
0
votes
1answer
267 views

SQL search multiple columns with priority

I'm trying to implement the search in pset8 and want to find the most elegant and fast solution. The way I have implemented it is to first of all check whether the search term is an int, and if so, ...
0
votes
0answers
117 views

How to check if an SQL table exists without relying on errors?

pset7 help pls. Trying to check if a table exists. I am getting the error "information_schema.tables does not exist". I guess information_schema is not there in our SQL version? How else could I ...