Log in to sqlite3 via the command line
The sky is the limit with SQLite -- once you're logged in. Here's the first crucial step.
Open your command line utility (Terminal on the Mac).
Use a few UNIX commands to get your whereabouts:
Type pwd
(print working directory) to see your directory location.
Type ls
(list) to view which files are in that directory.
Type cd
(change directory) followed by the desired directory's path.
Once you've navigated to the directory where your data lives, start the SQLite program by typing sqlite3
The system will immediately list basic details about the program you've entered
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
Following these details you will see the command line prompt has changed to sqlite>. This means you can now enter SQL statements and see results. End each statement with a semicolon and press return to execute.
Optionally, when you first type sqlite3
to launch the program, you can also type the name of the database file on the same line and then press return to enter that database right away.
If the database file does not exist, SQLite will automatically create a new one with the given name as a temporary file. SQLite will delete the file once you exit sqlite3).
Tips
Enter .help for usage hints.
Press ctrl-D to terminate the sqlite3 program.
Press ctrl-C to stop a long-running SQL statement.
Example
Here's how to log in to SQLite and immediately create a new database named directory in the same command, followed by the creation of a table named "employees" with fields for name and hats:
$sqlite3 directory
sqlite> create table employees(name varchar(10), hats smallint);
sqlite> insert into employees values('Dan',3);
sqlite> insert into employees values('Jan',4);
Then query your new data right away by using the SELECT command:
sqlite> SELECT * from employees;
name | hats |
---|---|
Dan | 3 |
Jan | 4 |
Create structure
Import data from a csv
professed professor