-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring db setup to load data into remote db (#22)
- Loading branch information
Showing
8 changed files
with
67 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
#!/usr/bin/bash | ||
#!/usr/local/bin/bash | ||
set -e | ||
|
||
DB_USER=${DB_USER:-postgres} | ||
DB_HOST=${DB_HOST:-localhost} | ||
DB_NAME=${DB_NAME:-nola311} | ||
data_dir=$(pwd)/data | ||
neighborhood_areas_file=$data_dir/neighborhood_areas.geo.json | ||
neighborhood_areas_file=$data_dir/neighborhood_areas.geo.json | ||
call_data_file=$data_dir/nola311_raw.csv | ||
|
||
echo "" | ||
echo "Setting up schema to load data into $DB_NAME on $DB_HOST" | ||
echo "" | ||
psql -U $DB_USER -d $DB_NAME -h $DB_HOST -f setup/setup_schema.sql | ||
|
||
echo "" | ||
echo "Loading data from $call_data_file" | ||
echo "This may take a minute..." | ||
echo "" | ||
psql -U $DB_USER -d $DB_NAME -h $DB_HOST \ | ||
-c "\copy nola311.calls_tmp(ticket_id,issue_type,ticket_created_date_time,ticket_closed_date_time,ticket_status,issue_description,street_address,neighborhood_district,council_district,city,state,zip_code,location,geom,latitude,longitude) from '$call_data_file' with csv header NULL as '';" | ||
|
||
echo "" | ||
echo "Loading data from $neighborhood_areas_file" | ||
echo "" | ||
psql -U $DB_USER -d $DB_NAME -h $DB_HOST \ | ||
-c "\copy nola311.neighborhood_areas_tmp(json_data) from '$neighborhood_areas_file' csv quote e'\x01' delimiter e'\x02';" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters