File: _postgres.Rmd

package info (click to toggle)
r-cran-dbplyr 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,644 kB
  • sloc: sh: 13; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 597 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

```{r, eval = FALSE}
library(DBI)
con <- dbConnect(RPostgres::Postgres(), dbname = "hadley")
dbListTables(con)

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