Skip to main content

Questions tagged [sqlite]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
10 views

Opening .db files in SQL

I am trying to open the shows.db file in CS50 Week 7. I have downloaded the file and it is present in the cs50.dev window. But, when I enter the following command, I am getting the following error: ...
Aniruddha Shirodkar's user avatar
0 votes
1 answer
35 views

Check if added value corresponds to value/id from another table - SQL Final Project

I'm working on SQL Final project and I decided to create a database for a gym franchise. How can I make sure that a client can join classes only to which they have a card for (correct access level and ...
phnlg's user avatar
  • 1
0 votes
0 answers
14 views

Why I do not receive full points on the final SQL Project?

I create all the requirments for this project but I still get only 2 of 3 point and can not pass. https://cs50.harvard.edu/sql/2023/project/ Do someone know what is going on ?
PeterWolfe's user avatar
0 votes
2 answers
324 views

CS50 SQL problem set 3 Meteorite Cleaning: NULL values are not present in "meteorites" table

Problem link: https://cs50.harvard.edu/sql/2023/psets/3/meteorites/ As the problem mentioned, any empty values in meteorites.csv are represented by NULL in the meteorites table. When I run the sqlite3 ...
yzrtt22's user avatar
0 votes
0 answers
62 views

PSet7 Fiftyville: Two possible thieves and accomplices left, can't figure out how to narrow it down further

I've narrowed who the thief and accomplice are down to two choices, but I can't figure out how to narrow it down further (I already have where the thief escaped to). The only tables I haven't used are ...
They think im slow EH's user avatar
0 votes
1 answer
76 views

CS50 pset9: Why does 'SELECT last_insert_rowid()' return 0 instead of the expected value when using CS50 SQL library in Flask?

symbol_id = db.execute("SELECT symbol_id FROM symbols WHERE symbol = ?", quote["symbol"]) if not symbol_id: db.execute("INSERT INTO symbols (symbol) VALUES ...
khalildouis's user avatar
0 votes
1 answer
912 views

CS50 Finance ValueError: FOREIGN KEY constraint failed

this error has getting me for a while now. From what I researched, it commonly occurs when inserting a wrong type in a column field or a value in the wrong order. Even though it appears in check50, I ...
Gustavo Oliveira's user avatar
0 votes
1 answer
271 views

CS50 PSET7 Movies "query did not return results" 12.sql

First timer asking on Stack Exchange. I have a SQL query that returns 6 results in the terminal but does not work with check50 resulting in "Query did not return any results" I read in a ...
DavidLS7's user avatar
0 votes
2 answers
1k views

My code gives error RuntimeError: no such table: File_Name

This is simplified version of my code from cs50 import SQL open("File_Name", "w").close() db = SQL("sqlite:///File_Name") id = 2 filename="hola" db.execute(&...
Inderveer's user avatar
0 votes
1 answer
94 views

CS50 Final Project Help: SQL QUERY...inserting row from one table into another table after button pressed

I have nearly finished the Cs50x course but I am stuck on my final project. I am creating a website called 'Letterbooks' (inspired by Letterboxd) that allows you to log books that you have read. I am ...
H S's user avatar
  • 1
0 votes
1 answer
229 views

Week 9 - I need a help about UNIQUE constraint

I am solving the week 9 problem using python. And I am interested in knowing how to deal with the error below using the if and elif? For example: rows = db.execute("SELECT username FROM users ...
Code Maker's user avatar
0 votes
1 answer
2k views

Check if query returns empty value

I am trying to check using (IF / ELSE) if my query returns any value. What is the simplest way to do this? Thanks result = db.execute("SELECT * FROM home WHERE id = ? AND name = ?", str(conn)...
Code Maker's user avatar
0 votes
1 answer
275 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. ...
Abdul's user avatar
  • 3
0 votes
1 answer
234 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 ...
user14720865's user avatar
0 votes
1 answer
97 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 ...
AlonsoLo's user avatar
0 votes
0 answers
205 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 ...
Leonidas Smiley's user avatar
0 votes
1 answer
81 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 ...
SozDaneron's user avatar
0 votes
1 answer
117 views

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 ...
M Husseini's user avatar
0 votes
1 answer
460 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) ...
StimpakNeeded's user avatar
0 votes
1 answer
746 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 ...
kcoak1's user avatar
  • 3
0 votes
1 answer
746 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. ...
Afrah Saleem's user avatar
1 vote
1 answer
833 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"...
Hama Ijaz's user avatar
0 votes
1 answer
339 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, ...
Librarian's user avatar
0 votes
1 answer
477 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....
RomanBlade's user avatar
0 votes
2 answers
642 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 ...
JJuice's user avatar
  • 119
0 votes
1 answer
143 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 ...
Jake 's user avatar
  • 37
0 votes
2 answers
1k 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 ...
PrawnBallNightmare's user avatar
2 votes
1 answer
393 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 ...
johnlock1's user avatar
0 votes
1 answer
244 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). ...
Matt Friend's user avatar
0 votes
1 answer
1k 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 ...
Poliphria's user avatar
0 votes
1 answer
119 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 ...
whodunit's user avatar
0 votes
0 answers
23 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 ...
mathmagician's user avatar
0 votes
1 answer
687 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 ...
Salamit's user avatar
  • 231
0 votes
1 answer
209 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: @...
SamGal's user avatar
  • 72
0 votes
0 answers
107 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....
Austris's user avatar
1 vote
1 answer
692 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 '...
Salamit's user avatar
  • 231
1 vote
1 answer
541 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 ...
Matt Friend's user avatar
1 vote
1 answer
49 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 (:...
Mefhisto1's user avatar
  • 111
0 votes
1 answer
760 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: (...
James Goldstein's user avatar
0 votes
2 answers
76 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 ...
Alex Chan's user avatar
  • 121
0 votes
1 answer
2k 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 ...
atefsawaed's user avatar
0 votes
1 answer
52 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 ...
Ahmed Raza's user avatar
0 votes
1 answer
389 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(...
Osman Zakir's user avatar
1 vote
1 answer
507 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, ...
Steve Bunting's user avatar
0 votes
0 answers
164 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 ...
Sank Finatra's user avatar
1 vote
2 answers
2k 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 ...
Ryan's user avatar
  • 138