SQL SELECT returns True when it begins with a comment
brianyu28 opened this issue · 0 comments
brianyu28 commented
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.dbAnd 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 usersthe program prints the contents of the table, but if query.sql contains
-- Get all users
SELECT * FROM usersthen the return of db.execute is just True.