Skip to content

Commit

Permalink
Added a script to setup a database.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Aug 16, 2014
1 parent 2206ab6 commit 3431cd0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bin/make_db
@@ -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

0 comments on commit 3431cd0

Please sign in to comment.