PY4E: Chapter 15 (Part 3)- Questions with
Solutions| Latest Update
What method do you call in an SQLIte cursor object in Python to run an SQL command?
ANSWER-execute()
In the following SQL,
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
what is the purpose of the "?"? ANSWER-It is a placeholder for the contents of the "org"
variable
In the following Python code sequence (assuming cur is a SQLite cursor object),
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
row = cur.fetchone()
what is the value in row if no rows match the WHERE clause? ANSWER-None
What does the LIMIT clause in the following SQL accomplish?
SELECT org, count FROM Counts
ORDER BY count DESC LIMIT 10 ANSWER-It only retrieves the first 10 rows from
the table
What does the executescript() method in the Python SQLite cursor object do that the normal
execute() method does not do? ANSWER-It allows multiple SQL statements separated by
semicolons
Solutions| Latest Update
What method do you call in an SQLIte cursor object in Python to run an SQL command?
ANSWER-execute()
In the following SQL,
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
what is the purpose of the "?"? ANSWER-It is a placeholder for the contents of the "org"
variable
In the following Python code sequence (assuming cur is a SQLite cursor object),
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
row = cur.fetchone()
what is the value in row if no rows match the WHERE clause? ANSWER-None
What does the LIMIT clause in the following SQL accomplish?
SELECT org, count FROM Counts
ORDER BY count DESC LIMIT 10 ANSWER-It only retrieves the first 10 rows from
the table
What does the executescript() method in the Python SQLite cursor object do that the normal
execute() method does not do? ANSWER-It allows multiple SQL statements separated by
semicolons