Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a script to setup a database.

  • Loading branch information...
commit 3431cd0b729d9c9621bb79c5b6d67f0775a98535 1 parent 2206ab6
Dave Cross authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 bin/make_db
26 bin/make_db
View
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [[ -z $TE_DB || -z $TE_HOST || -z $TE_USER || -z $TE_PASS ]]
+then
+ echo You must set TE_HOST, TE_DB, TE_USER and TE_PASS
+ exit 1
+fi
+
+# Drop existing database
+echo "DROP DATABASE IF EXISTS $TE_DB" | mysql -u$TE_USER -p$TE_PASS
+
+# Create databsae
+echo "CREATE DATABASE $TE_DB" | mysql -u$TE_USER -p$TE_PASS
+
+# Load DDL
+mysql -u$TE_USER -p$TE_PASS -D$TE_DB < db/twittelect.sql
+
+# Load data
+mysql -u$TE_USER -p$TE_PASS -D$TE_DB < db/constituency.dat
+mysql -u$TE_USER -p$TE_PASS -D$TE_DB < db/party.dat
+
+if [[ -f db/candidate.csv ]]
+then
+ bin/load_cand
+fi
+
Please sign in to comment.
Something went wrong with that request. Please try again.