Questions tagged [sqlite]

The tag has no usage guidance.

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

11.sql Why my SQL SELECT query changes order?

When i execute this query: SELECT movie_id FROM ratings WHERE movie_id IN ( SELECT movie_id FROM stars WHERE person_id IN ( SELECT id FROM people WHERE name='...
user avatar
0 votes
0 answers
6 views

PSET 9: Should I use a separate table for symbols?

Symbols will repeat themselves, since different users can buy shares from the same company, so when creating the portfolio table to store data related to the purchase of shares, I thought I could ...
user avatar
0 votes
1 answer
25 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 ...
user avatar
0 votes
1 answer
69 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(&...
user avatar
0 votes
1 answer
29 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 ...
user avatar
  • 1
0 votes
1 answer
90 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 ...
user avatar
0 votes
1 answer
64 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)...
user avatar
0 votes
1 answer
79 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. ...
user avatar
  • 3
0 votes
1 answer
73 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 ...
user avatar
0 votes
1 answer
59 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 ...
user avatar
0 votes
0 answers
118 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 ...
user avatar
0 votes
1 answer
42 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 ...
user avatar
0 votes
1 answer
47 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 ...
user avatar
0 votes
1 answer
333 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) ...
user avatar
0 votes
1 answer
404 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 ...
user avatar
  • 3
0 votes
1 answer
622 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. ...
user avatar
1 vote
1 answer
825 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"...
user avatar
0 votes
1 answer
290 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, ...
user avatar
0 votes
1 answer
361 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....
user avatar
0 votes
2 answers
479 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 ...
user avatar
  • 119
0 votes
1 answer
123 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 ...
user avatar
  • 37
0 votes
2 answers
692 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 ...
user avatar
2 votes
1 answer
392 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 ...
user avatar
0 votes
1 answer
178 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). ...
user avatar
0 votes
1 answer
863 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 ...
user avatar
0 votes
1 answer
107 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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
0 votes
1 answer
601 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 ...
user avatar
  • 231
0 votes
1 answer
198 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: @...
user avatar
  • 62
0 votes
0 answers
104 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....
user avatar
1 vote
1 answer
529 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 '...
user avatar
  • 231
1 vote
1 answer
500 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 ...
user avatar
1 vote
1 answer
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 (:...
user avatar
  • 111
0 votes
1 answer
648 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: (...
user avatar
0 votes
2 answers
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 ...
user avatar
  • 121
0 votes
1 answer
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 ...
user avatar
0 votes
1 answer
51 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 ...
user avatar
0 votes
1 answer
343 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(...
user avatar
0 votes
1 answer
371 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, ...
user avatar
0 votes
0 answers
128 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 ...
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 ...
user avatar
  • 138