Skip to content

SQL SELECT returns True when it begins with a comment #96

Closed
@brianyu28

Description

@brianyu28

Not sure if this is expected, but caused some issues for check50...

Let's say we set up a database as:

$ echo "CREATE TABLE users (name TEXT); INSERT INTO users (name) VALUES ('Alice')" | sqlite3 foo.db

And run the following Python program:

from cs50 import SQL
db = SQL("sqlite:///foo.db")
with open("query.sql") as f:
    print(db.execute(f.read()))

If query.sql contains

SELECT * FROM users

the program prints the contents of the table, but if query.sql contains

-- Get all users
SELECT * FROM users

then the return of db.execute is just True.

cc @dmalan @kzidane

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions