notes/postgres-setup.Rmd

Setting up Postgresql

Install

First install postgresql, create a data directory, and create a default database.

brew install postgresql
export PGDATA=~/db/postgres-9.5 # set this globally somewhere
initdb -E utf8
createdb
createdb lahman
createdb nycflightd13

Start

pg_ctl start

Connect

install.packages("RPostgreSQL") library(DBI) con <- dbConnect(RPostgreSQL::PostgreSQL(), dbname = "hadley") dbListTables(con)