Skip to content

Instantly share code, notes, and snippets.

@maurimiranda
Created August 1, 2013 20:05
Show Gist options
  • Select an option

  • Save maurimiranda/6134744 to your computer and use it in GitHub Desktop.

Select an option

Save maurimiranda/6134744 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -ne 6 ]
then
echo "Usage: `basename $0` host user password database limit outfile"
exit
fi
host=$1
user=$2
password=$3
database=$4
limit=$5
outfile=$6
mysql -h $host \
-u$user \
-p$password \
$database \
-e "SELECT
city,
state,
zip,
zip4,
gender,
age,
membership_type,
membership_status,
secondary_member_age,
original_financial_participation_date,
lastest_financial_participation_date,
historical_financial_participation_count,
current_financial_participation_count,
income_range,
internet_usage,
networth_range,
completed_school_years,
lifestage_segment,
investment_score,
children_score,
webuse_score
FROM api_person
LIMIT $limit;" \
| sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" \
> $outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment