A PostgreSQL Cheat Sheet for OSX and R

2015-01-23

I keep this on my desktop.

Install:

brew install postgresql
initdb /usr/local/var/postgres -E utf8
gem install lunchy
### Start postgres with lunchy
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.3.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

Setup DB from SQL file:

### Setup DB
lunchy start postgres
created $DBNAME
psql -d $DBNAME -f '/path/to/file.sql'
lunchy stop postgres

Starting and Stopping PostgreSQL

lunchy start postgres
lunchy stop postgres

may run into trouble with local socket… try this:

rm /usr/local/var/postgres/postmaster.pid

Connecting with R

# make sure lunch start postgres in terminal first)
require(dplyr)
db <- src_postgres(dbname=$DBNAME)

Inspired by seeing this post and thought I should toss out what I do.

This entry was tagged as rstats posgresql osx

Jan 11, 2015

Taking Control

Severing My Daemon

When I was in high school, I piggy-backed on a friend’s website to host a page for my band. We could post pictures, show locations and dates, lyrics, and pretend like we produced music people cared about. It was mostly a fun way for me to ...

Nov 28, 2014

The Power Of Sound

It has been said a thousand times before, but I feel the need to say it again. So much of what Star Wars got right was creating a fully realized, fascinating world. As much as stunning visual effects that have largely stood the test of time were a part of ...

Nov 28, 2014

Amazon Creating A Services Marketplace Online

A few thoughts:

  1. This is a very interesting way to take advantage of a number of existing Amazon technologies—primarily their payment processing and review system.
  2. Services are an increasingly important part of the economy and is less subject to commoditization. This is Amazon dipping into a massive growth area ...

Nov 19, 2014

School Funding Reform, Hard Work and Fraught with Potential

Because of the primacy of equity as a goal in school finance system design, the formulas disproportionately benefit less wealthy districts and those with high concentrations of needier students. … because of the universal impact on communities, school finance legislation requires broad political buy-in.

I think it is worth contrasting the ...