Description Details Author(s) Examples
A set of methods useful for connecting to Amazon Redshift database. These functions are mostly wrappers around JDBC methods. The main advantage are methods for quick (bulk) inserting of data and retrieving of data into data frames. These functions are type aware.
Package: | keboola.redshift.r.client |
Type: | Package |
Version: | 1.0 |
Date: | 2015-04-28 |
License: | MIT |
Maintainer: Ondrej Popelka <ondrej.popelka@keboola.com>
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 | ## Not run:
# connect to database
driver <- RedshiftDriver$new()
driver$connect("myhost.example.com", "mydb", "user", "passwrod", "myschema")
# insert some data
df <- data.frame("foo" = c(1,3,5), "bar" = c("one", "three", "five"))
driver$saveDataFrame(df, "fooBar")
# select data (return a data.frame)
dfResult <- driver$select("SELECT foo, bar, row_num FROM fooBar ORDER BY foo")
# optionally insert row numbers from the data frame
driver$saveDataFrame(df, "fooBar", rowNumbers = TRUE)
dfResult <- driver$select("SELECT foo, bar, row_num FROM fooBar ORDER BY row_num")
# optionally insert data to an existing table
driver$update(
paste0("CREATE TABLE ", schema, ".fooBar (foo INTEGER, bar CHARACTER VARYING (200));")
)
driver$saveDataFrame(df, "fooBar", incremental = TRUE)
# utility methods
cols <- driver$columnTypes(paste0(schema, ".fooBar"))
cols[["foo"]] # -> "integer"
driver$tableExists("fooBar") # -> TRUE
# for DML and DML statements use the update method
driver$update("DROP TABLE IF EXISTS fooBar;")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.