Skip to content

Instantly share code, notes, and snippets.

@javierluraschi
Created September 15, 2017 00:42
Show Gist options
  • Save javierluraschi/010a4efd60baee82582765671a4e71ea to your computer and use it in GitHub Desktop.
Save javierluraschi/010a4efd60baee82582765671a4e71ea to your computer and use it in GitHub Desktop.
RPostgreSQL in OS X
## install
```{bash}
brew install postgres
```
## start
```{bash}
pg_ctl -D /usr/local/var/postgres -l logfile start
postgres -D /usr/local/var/postgres
createdb mydb
```
## initdb
```{bash}
psql mydb
create table users(id serial, name varchar(25));
insert into users(name) values('eric');
\quit
```
## RPostgreSQL
```{r}
dplyr::src_postgres(dbname = "mydb", port = "5432", host = "localhost")
```
## stop
pg_ctl -D /usr/local/var/postgres stop -s -m fast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment