Create populate.sqlite3 to simplify README

To make my life easier, I created a small sqlite3 script to populate our
database.
This commit is contained in:
William Carroll 2020-07-28 18:42:07 +01:00
parent 36a2fea686
commit 191205acac
3 changed files with 15 additions and 24 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
*.db
*.sqlite3
!populate.sqlite3
*.db-shm
*.db-wal

View file

@ -34,34 +34,17 @@ Create a new database named `db.sqlite3` with:
$ sqlite3 db.sqlite3
```
Initialize the schema with:
Populate the database with:
```
sqlite> .read src/init.sql
sqlite3> .read populate.sqlite3
```
You can verify that you successfully initialized the database by running:
You can verify that everything is setup with:
```
sqlite> .tables
sqlite> .schema Accounts
sqlite> .schema Trips
```
Populate the database with some dummy values using the following:
```
sqlite> PRAGMA foreign_keys = on;
sqlite> .mode csv
sqlite> .import data/accounts.csv Accounts
sqlite> .import data/trips.csv Trips
```
You can verify you successfully populated the tables with:
```
sqlite> .mode columns
sqlite> .headers on
sqlite> SELECT * FROM Accounts;
sqlite> SELECT * FROM Trips;
sqlite3> .tables
sqlite3> .schema
sqlite3> SELECT * FROM Accounts;
sqlite3> SELECT * FROM Trips;
```

7
populate.sqlite3 Normal file
View file

@ -0,0 +1,7 @@
PRAGMA foreign_keys = on;
.read src/init.sql
.mode csv
.import data/accounts.csv Accounts
.import data/trips.csv Trips
.mode column
.headers on