Optional: Check that you have added the location of the program to your local PATH environment variable as this will make it easier to refer to the database file and other files we may want to use.
Open a command prompt and cd to the folder location of the SN7577.sqlite database file.
run the command sqlite3 This should open the SQLite shell and present a screen similar to that below.
By default a transient in-memory database is opened. You can change the database by use of the .open command
.open SN7577.sqlite
It is imprtant to remember the .sqlite suffix, otherwise a new database simply called SN7577 would be created
Once the database is opened you can run queries by typing directly in the shell.
terminate your select command with a ;.
This is how the shell knows that You think the statement is complete.
Although easy to forget, it generally works to your advantage as it allows you to split a long query command across lines as you did in the DB Browser application.
use example
SELECT *
FROM question1;
The output from the query is displayed on the screen. If we just wanted to look at a small selection of data this may be OK. It is however more likely that not only are the results from the query somewhat larger, but also we would prefer to save the output to a file for later use. We might also want to change the field seperator from the default “|” to a comma so that we get a standard csv file.
These problems can be resolved with further “dot” commands.
There are in fact a large number of “dot” commands and they are all explained in the official SQLite documentation here.
The commands we need are:
.mode csv
to change the field seperatator to ,. There are many other modes available see the documentation. https://sqlite.org/cli.html
.output my.filename
to direct the output to a file of my choice.
The file will be created if needed or it will overwrite an already existing file, so exercise care.
The contents of the output file contains the expected output from the query in CSV format.