-
Write the regular expression that is equivalent to *
on the Unix command line.
.*
-
What is the name of the module that allows Python to work with a SQLite
database?
sqlite3
-
What would you enter at the command line if you wanted a SQLite command
line that let you work with the database contained in the file
work.db?
sqlite3 work.db
-
If you were writing a Python script that needed to work with
a SQLite database what is the first thing you would
have to create?
a connection object to the database
-
Write the Python statement that would create the thing mentioned above
on the SQLite file work.db.
con = sqlite3.connect("work.db")
-
Once you have the thing mentioned above, what is the next thing you
have to create?
a cursor object
-
Write a Python statement that creates this thing.
cur = con.cursor()
-
What must you do to make sure the changes you have made to
a table are saved?
commit the changes
-
Write the Python statement to perform the action mentioned above.
con.commit()
-
Write the Python statement to run the query
select * from students
using the cursor cur.
cur.execute("select * from students")
-
Write the Python statements to print the results of the previous query.
for row in cur:
print(row)