RedshiftDriver-class: Class to access Redshift database

Description Fields Methods

Description

Class to access Redshift database

Fields

conn

Database connection (JDBCConnection)

schema

Current database schema

Methods

columnTypes(tableName)

Get list of columns in table and their datatypes.

Parameters

  • tableName Name of the table (without schema).

Return Value

Named vector, name is column name, value is datatype.

connect(host, db, user, password, schema, port = 5439)

Connect to Amazon Redshift database.

Parameters

  • jdbcUrl JDBC connection string.

  • username Database user name.

  • password Database password.

  • schema Database schema.

  • port Database server port.

Return Value

TRUE

fetch(statement, maxmem = 5e+08, chunksize = -1)

Select via JDBC result set fetching to avoid memory restraints.

Parameters

  • statement Prepared Query statement.

  • maxmem Upper limit in bytes of read - default 500MB.

  • chunksize Rows to return per fetch - default 32k for 1st fetch, then 512k.

Return Value

A data.frame with results

prepareStatement(sql, ...)

Prepare a SQL query with quoted parameters.

Parameters

  • sql SQL string, parameter placeholders are marked with ?.

  • ... Query parameters, number of parameters must be same as number of question marks.

Return Value

SQL string

saveDataFrame(dfRaw, table, rowNumbers = FALSE, incremental = FALSE, forcedColumnTypes, displayProgress)

Save a dataframe to database using bulk inserts. The table will be created to accomodate to data frame columns.

Parameters

  • dfRaw A data.frame, column names of data frame must correspond to column names of table.

  • table Name of the table.

  • rowNumbers If true then the table will contain a column named 'row_num' with sequential row index

  • incremental If true then the table will not be recreated, only data will be inserted.

  • forcedColumnTypes Optional list of column names and their respective types in database.

  • displayProgress Optional logical, if set to true, saving progress will be displayed.

Return Value

TRUE

select(sql, ...)

Select data from database.

Parameters

  • sql Query string, may contain placeholders ? for parameters.

  • ... Query parameters, number of parameters must be same as number of question marks.

Return Value

A data.frame with results

tableExists(tableName)

Verify that a table exists in database.

Parameters

  • tableName Name of the table (without schema).

Return Value

TRUE if the table exists, FALSE otherwise.

update(sql, ...)

Update/Insert data to database.

Parameters

  • sql Query string, may contain placeholders ? for parameters.

  • ... Query parameters.

Return Value

TRUE


keboola/redshift-r-client documentation built on May 20, 2019, 8:34 a.m.