In this page we demonstrate how to initialize a database. There is a lot going on here so study each step in turn.
  1. Start a connection
    Connection successful.
  2. Delete old tables. Here we want to use exec() because the drop command does not return a queryset but instead number of rows effected. (Note: Always returns 0 when deleting or creating tables.)

    Delete artist:

    Number of rows effected: 0

    Delete albums:

    Number of rows effected: 0
  3. Create Tables. The SQL here is the same as if you were doing it via command line

    Artist Table

    Number of rows alterred: 0

    Albums Table

    Number of rows effected: 0
  4. Load Values Into Database
  5. Check Values (should be 100 albums and fewer artists since The Beatles and Led Zepplin Rock.

    Number of artists: 65
    Number of albums: 100