No description
Find a file
William Carroll 6d9e76313d Partially support DELETE /trips
Allow a user to delete a trip entry from the Trips table using the Primary
Key. While this type-checks and compiles, it doesn't appear to be working as
intended. Perhaps I should use an auto-incrementing integer as the Primary
Key. I'm not sure how I want to handle this, so I'm punting for now.
2020-07-28 10:14:33 +01:00
data Define table schema and CSVs to populate the database 2020-07-27 11:16:26 +01:00
src Partially support DELETE /trips 2020-07-28 10:14:33 +01:00
.gitignore Define table schema and CSVs to populate the database 2020-07-27 11:16:26 +01:00
README.md Add instruction for operating the server 2020-07-27 11:36:09 +01:00
shell.nix Integrate Persistent with Servant 2020-07-24 22:48:08 +01:00
todo.org Create todo.org 2020-07-24 18:58:04 +01:00

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:

$ nix-shell

To run the server interactively, run:

$ 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:

$ 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;