Django: Getting Started Transcripts
Chapter: Django ORM and Databases
Lecture: Exploring the resulting database

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I'm back in my bash terminal, this time, I'm going to show you the effects of all that object creation. I have a copy of sqlite admin installed.
0:09 Let me just open up the database that Django created. The tables command in sqlite lists all the tables in the database.
0:22 There's much more here than you might have expected. That's because Django sets up a bunch of user management stuff
0:27 and configuration stuff in the database for you. All the tables starting with off underscore are user management.
0:35 The two tables starting with catalog are the two models, the model maps to a table named appname_modelname.
0:46 There are ways of changing this but there's seldom reason to bother. The tables that begin with Django, our system storage.
0:53 The Django migrations table is the one that tracks
55:01 the current state of all your model migrations. Let me select everything in the catalog book table and you get a row for each book that was created.
1:07 The pipe symbol is used to separate the table columns in the print out. The first column is the primary key, the objects automatically created id.
1:17 The second column is the text field containing the title. The 3rd and 4th columns are the created and updated timestamps and the last column is
1:26 the foreign key for the author table. I only ever created one author whose id was one and so the value is the same for all three of these books.
1:37 Let me select everything from the authors now and you get back good old Chuck. control deed, exit sqlite And I'm back in my shell.
1:48 Django also provides a management command that does essentially the same thing. Why you might ask,
1:54 so you don't have to remember the name of your database command line tool. You can just use the Django one.
2:03 Running the dbshell command gets me to the same places before and just to prove that I've run tables again.


Talk Python's Mastodon Michael Kennedy's Mastodon