Learn R Programming

nodbi (version 0.10.7)

src_postgres: Setup a PostgreSQL database connection

Description

Setup a PostgreSQL database connection

Usage

src_postgres(dbname = "test", host = "localhost", port = 5432L, ...)

Value

A nodbi source object

Arguments

dbname

(character) name of database, has to exist to open a connection

host

(character) host of the database, see RPostgres::Postgres()

port

(integer) port of the database, see RPostgres::Postgres()

...

additional named parameters passed on to RPostgres::Postgres()

Details

Uses RPostgres as backend. nodbi creates or uses a PostgreSQL table, with columns _id and json created and used by package nodbi, applying SQL functions as per https://www.postgresql.org/docs/current/functions-json.html to the json column. Each row in the table represents a JSON document. Any root-level _id is extracted from the document(s) and used for column _id, otherwise a UUID is created as _id. The table is indexed on _id. A custom plpgsql function jsonb_merge_patch() is used for docdb_update(). The order of variables in data frames returned by docdb_get() and docdb_query() can differ from their order the input to docdb_create(). For a benchmark, see https://github.com/ropensci/nodbi#benchmark

Examples

Run this code
if (FALSE) {
con <- src_postgres()
print(con)
}

Run the code above in your browser using DataLab