MyRedshift: A class for interacting with Redshift

MyRedshiftR Documentation

A class for interacting with Redshift

Description

This class can be used to interact with a Redshift database. Currently, only read operations— such as reading tables and query results from Redshift into R— are supported.

Public fields

host

Database host address.

port

Connection port number.

user

User name used to authenticate.

password

Database password.

dbname

Database name.

Methods

Public methods


Method new()

Instantiate a new MyRedshift object.

Usage
MyRedshift$new(host = NA, port = NA, user = NA, password = NA, dbname = NA)
Arguments
host

Database host address.

port

Connection port number.

user

User name used to authenticate.

password

Database password.

dbname

Database name.

Returns

A new MyRedshift object.


Method read_tbl()

A method for reading a table into a DataFrame. Warning: Reading large tables all at once may lead to memory issues. If the argument nrow is omitted, the entire table will be fetched. A value of Inf for the nrow argument is supported and also returns the full result. If more rows than available are fetched (by passing a value for nrow that is too large), the result is returned in full without warning. If zero rows are requested, the columns of the data frame are still fully typed. Fetching fewer rows than available is permitted, no warning is issued.

Usage
MyRedshift$read_tbl(table_name, nrow = -1L)
Arguments
table_name

Table name.

nrow

Number of rows to be fetched.

Returns

A DataFrame representing a table in the database.


Method read_sql()

A method for reading query results into a DataFrame. Warning: Large results may lead to memory issues. If the argument nrow is omitted, the rows will be returned. A value of Inf for the nrow argument is supported and also returns the full result. If more rows than available are fetched (by passing a value for nrow that is too large), the result is returned in full without warning. If zero rows are requested, the columns of the data frame are still fully typed. Fetching fewer rows than available is permitted, no warning is issued.

Usage
MyRedshift$read_sql(sql, nrow = -1L)
Arguments
sql

A character string containing SQL.

nrow

Number of rows to be fetched.

Returns

A DataFrame representing query results.


Method finalizer()

Resource cleanup.

Usage
MyRedshift$finalizer()

YangWu1227/citizenr documentation built on June 18, 2022, 12:17 p.m.