dbDriver-methods: PostgreSQL implementation of the Database Interface (DBI)...

Description Methods References See Also Examples

Description

PostgreSQL driver initialization and closing

Methods

drvName

character name of the driver to instantiate.

drv

an object that inherits from PostgreSQLDriver as created by dbDriver.

max.con

optional integer requesting the maximum number of simultanous connections (may be up to 100)

.

fetch.default.rec

default number of records to retrieve per fetch. Default is 500. This may be overridden in calls to fetch with the n= argument.

force.reload

optional logical used to force re-loading or recomputing the size of the connection table. Default is FALSE.

...

currently unused.

References

See the Database Interface definition document DBI.pdf in the base directory of this package or https://cran.r-project.org/package=DBI.

See Also

PostgreSQL, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo, dbListTables, dbReadTable.

Examples

 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
## Not run: 

# create an PostgreSQL instance and set 10000 of rows per fetch.
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL", fetch.default.records=10000)

# Connecting to PostgreSQL with the specified parameters
con <- dbConnect(drv,user="usrname",password="passwd",dbname="postgres")

# Running the query to obtain the resultset
rs <- dbSendQuery(con, "select * from cities where population > 5000")

# fetch records into a dataframe.
# n = 50 fetched fifty records
df <- fetch(rs, n = 50)
# n = -1 fetches all the remaining records available
df2 <- fetch(rs, n = -1)

# Clearing the result set
dbClearResult(rs)

#This returns a character vector (possibly of zero-length)
# table names available on the con connection.
dbListTables(con)

## End(Not run)

RPostgreSQL documentation built on May 2, 2019, 8:49 a.m.