L. J. Jaeckel                      ◄ Home        ◄ Back to Fedora log
CMPSC 210 – Linux System Administration
February 17, 2011

Transcript showing creation of the cs210class.db SQLite database

Note: This transcript is edited to make it a little more readable, and to make it an HTML page:

Nevertheless, I, Jay Jaeckel, hereby certify that this transcript, as shown here, substantially and correctly shows what actually happened.

Run the mkusers.sh shell script, which creates the database, the users table in the database, and inserts the data.
All the SQL to do this is written into this script:      Click here to view mkusers.sh

[jay@fizzle:~]$ ./mkusers.sh

Observe that the database file, cs210class.db, is there now:

[jay@fizzle:~]$ ls -l c*.db
-rw-r--r-- 1 jay jay 3072 Feb 17 19:11 cs210class.db

Now run sqlite3 interactively and view the data we just created:

[jay@fizzle:~]$ sqlite3 cs210class.db
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

sqlite> .databases
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main             /home/jay/cs210class.db                                   

sqlite> .tables
users

The default output format may be hard to read, but is designed to be easy to use if we want to capture it and parse it with sed, awk, cut, etc.:

sqlite> select * from users;
profdkp|Phillips|Dale
anetp|Police|Anet
aquigley|Quigley|Andrew
brasudo|Hernandez|Octavio
brazils|Brazil|Sean
camery|Mery|Claudia
doggie|Jaeckel|Jay
ejamn|Jamnadas|Elesh
ericg|Greenberg|Eric
kewl|Burton|Andrew
javargas|Vargas|Jesus
jnicklas|Nicklas|Judson
mencinas|Encinas|Margarita
rrawers|Rawers|Robert
zerocnc|Neal|Richard

Note, settings like the following mode, header, and width settings, could be put into a start-up file called .sqliterc in the user’s home directory:

sqlite> .mode column

sqlite> .header on

sqlite> .width 20, 20, 20

This gives us a more easily human-readable print-out:

sqlite> select * from users;
username              lastname              firstname           
--------------------  --------------------  --------------------
profdkp               Phillips              Dale                
anetp                 Police                Anet                
aquigley              Quigley               Andrew              
brasudo               Hernandez             Octavio             
brazils               Brazil                Sean                
camery                Mery                  Claudia             
doggie                Jaeckel               Jay                 
ejamn                 Jamnadas              Elesh               
ericg                 Greenberg             Eric                
kewl                  Burton                Andrew              
javargas              Vargas                Jesus               
jnicklas              Nicklas               Judson              
mencinas              Encinas               Margarita           
rrawers               Rawers                Robert              
zerocnc               Neal                  Richard             

sqlite> .quit

[jay@fizzle:~]$

Work remaining to do (another day):

End of transcript.        ◄ Home        ◄ Back to Fedora log