There are two major problems with this driver though: It lacks SSL support, and you don't have transactions like you do with the official driver. RPostgreSQL is configured like this: install.packages ( 'RPostgreSQL' ) library (RPostgreSQL ) RPostgreSQLĪmazon Redshift is mostly PostgreSQL compatible, so most PostgreSQL drivers work well. This package has some big problems though, which I'll explain later on this post. Until a few days ago since the writing of this blogpost, this was the recommended package for uploading data and inserting/deleting data, since you usually want be able to unite your operations which modify data into a single transaction. This package was the only one I found which supported transactions on Redshift ( BEGIN, COMMIT, ROLLBACK) until recently, otherwise on other packages DDL operations will autocommit. The first 3 lines you only need to run them once, they download Redshift's official JDBC driver and install the RJDBC package. Of course you can change the url with the options you need for your particular setup. Jconn <- dbConnect (driver, url, user, password ) Url <- sprintf ( "jdbc:redshift://%s:%s/%s?tcpKeepAlive=true&ssl=true&sslfactory=.NonValidatingFactory", host, port, dbname ) Install.packages ( 'RJDBC' ) suppressPackageStartupMessages (library (RJDBC ) ) # Use Redshift driverĭriver <- JDBC ( "41.Driver", "~/.redshiftTools/redshift-driver.jar", identifier.quote = "`" ) # Create connection This is the "official" way to use Amazon Redshift with R, using the JDBC driver on SQL Workbench/J is the official way to connect to it according to the documentation, and this driver can be loaded like this: # Save the driver into a directoryĭownload.file ( '', '~/.redshiftTools/redshift-driver.jar' ) For all of the connections, we'll define these variables for connecting: dbname = "dbname" First of all, let's go through the 3 options we have for connecting to Amazon Redshift.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |