PostgreSQL

Install

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

brew install postgresql
export PGDATA=~/db/postgres # set this globally somewhere
initdb
createdb test

psql -c "CREATE USER postgres WITH PASSWORD 'password';"
psql -c "ALTER USER postgres WITH SUPERUSER;"

Start

pg_ctl start

Connect

library(DBI)
con <- dbConnect(RPostgres::Postgres(), dbname = "hadley")
dbListTables(con)

con <- dbConnect(
  RPostgres::Postgres(), 
  dbname = "test", 
  user = "postgres", 
  password = "passowrd"
)


Try the dbplyr package in your browser

Any scripts or data that you put into this service are public.

dbplyr documentation built on May 29, 2024, 6:19 a.m.