blob: 2e5f2f18de0ec93eeb05192e6ccc54d58486dc7a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# TopTal take-home #2
All of the commands defined herein should be run from the top-level directory of
this repository (i.e. the directory in which this file exists).
## Server
To create the environment that contains all of this application's dependencies,
run:
```shell
$ nix-shell
```
To run the server interactively, run:
```shell
$ cd src/
$ ghci
```
Now compile and load the server with:
```
Prelude> :l Main.hs
*Main> main
```
## Database
Create a new database named `db.sqlite3` with:
```shell
$ sqlite3 db.sqlite3
```
Initialize the schema with:
```
sqlite> .read src/init.sql
```
You can verify that you successfully initialized the database by running:
```
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;
```
|