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:
parent
36a2fea686
commit
191205acac
3 changed files with 15 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
*.db
|
||||
*.sqlite3
|
||||
!populate.sqlite3
|
||||
*.db-shm
|
||||
*.db-wal
|
31
README.md
31
README.md
|
@ -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
7
populate.sqlite3
Normal 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
|
Loading…
Reference in a new issue