IT 117: Intermediate to Scripting
Answers to Class 16 Ungraded Quiz

  1. Write the regular expression that is equivalent to * on the Unix command line.
    .*
  2. What is the name of the module that allows Python to work with a SQLite database?
    sqlite3
  3. 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
  4. 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
  5. Write the Python statement that would create the thing mentioned above on the SQLite file work.db.
    con = sqlite3.connect("work.db")
  6. Once you have the thing mentioned above, what is the next thing you have to create?
    a cursor object
  7. Write a Python statement that creates this thing.
    cur = con.cursor()
  8. What must you do to make sure the changes you have made to a table are saved?
    commit the changes
  9. Write the Python statement to perform the action mentioned above.
    con.commit()
  10. Write the Python statement to run the query
    select * from students
    using the cursor cur.
    cur.execute("select * from students")
  11. Write the Python statements to print the results of the previous query.
    for row in cur:
        print(row)