ROracle Error in .oci.Driver - r

I'm trying to use ROracle. My Oracle database version is Oracle Database 12c Release 12.1.0.1.0 - 64bit Production, and I have installed Instant Client and SDK for the version 12.1.0.2.0 (12.1.0.1.0 isn't available on Oracle's site).
I can access the Oracle database through Oracle SQL Developer without any issues. The error message I get in RStudio is:
Error in .oci.Driver(.oci.drv(), interruptible = interruptible, unicode_as_utf8 = unicode_as_utf8, :
In case it's useful, I have installed Instant Client and SDK here:
C:\oreclient_install_dir\instantclient_12_1
I'm running a Windows machine and I followed the instructions on CRAN:
http://cran.us.r-project.org/web/packages/ROracle/INSTALL
Including adding the environment variables.
After some searching (e.g. here) it looks like I need to set LD_LIBRARY_PATH and ORACLE_HOME and "OCI_LIB", which I did:
Sys.setenv(LD_LIBRARY_PATH="C:/oreclient_install_dir/instantclient_12_1")
Sys.setenv("ORACLE_HOME" = "C:/oreclient_install_dir/instantclient_12_1")
Sys.setenv("OCI_LIB" = "C:/oreclient_install_dir/instantclient_12_1")
Same error comes up. I'm likely not doing this right, however; I'm not a DBA and don't know all the details.
Any help with this would be appreciated.

LD_LIBRARY_PATH is for Linux. Assuming that you already have Rtools installed in C:\Rtools, you can use the following code to install ROracle
Sys.setenv(OCI_LIB64="C:\\oreclient_install_dir\\instantclient_12_1")
Sys.setenv(PATH=paste0(Sys.getenv("PATH"),";C:\\oreclient_install_dir\\instantclient_12_1"))
install.packages("ROracle", type="source", INSTALL_opts="--no-multiarch")
For using the ROracle package, you can use the following:
Sys.setenv(OCI_LIB64="C:\\oreclient_install_dir\\instantclient_12_1")
Sys.setenv(PATH=paste0(Sys.getenv("PATH"),";C:\\oreclient_install_dir\\instantclient_12_1"))
library(ROracle)

Related

Azure Machine Learning integration of R: Should the 'azureml' module have an attribute 'core'?

I'm having issues with Azure Machine Learning SDK for R: "module 'azureml' has no attribute 'core'"...
For reasons that aren't my own, I have to use azureml to apply machine learning (my own stuff, written in R) to data from our data warehouse that is put in the blob storage. The modelled output should be put back into the blob storage so it can be accessed from the data warehouse.
I've written the code in R on my local machine (stored in a git repo). Preferably, I'd find some method to pull my code from git into a pipeline in the azureml environment so that it can be directly run whenever new data is available in the blob storage.
I've embarked on a tutorial-spree and found this seemingly relevant walkthrough: Train and deploy your first model with Azure ML (and this one).
But... after trying all I could think of, I'm stuck on the first steps. After installing all (or at least.. that's what I think) packages, modules, apps etc, and running the following code in RStudio:
library(azuremlsdk)
existing_ws <- get_workspace(name = name,
subscription_id = subscription_id,
resource_group)
I run into an error that I haven't been able to fix:
AttributeError: module 'azureml' has no attribute 'core'
It seems that the azuerml is supposed to have an attribute "core", but when looking at it more closely, there is indeed no such attribute.
The function "get_workspace()" is trying to access: "azureml$core$Workspace$get".
I found that "azuerML$Workspace" does exist, but then I can't figure out how to make that work.
Can anyone explain to me why I'm encountering this error?
Does anyone know of a better tutorial on how to connect my R code the azureml's cloud service?
Any pointers in the right direction are much appreciated!
EDITS - still not solved:
After advice from others, I double, triple and quadruple checked the installation.
I updated R and I'm now running:
R.version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.2
year 2019
month 12
day 12
svn rev 77560
language R
version.string R version 3.6.2 (2019-12-12)
nickname Dark and Stormy Night
I installed Conda with Python 3.6.10.
I installed the azuremlsdk R package (I tried both provided options).
I then realized that there are some inconsistencies with the versions of the azure-modules, so I also tried installing it with the keyword 'multi-arch':
remotes::install_cran('azuremlsdk', repos = 'http://cran.us.r-project.org', INSTALL_opts=c("--no-multiarch"))
Then, I installed the azureml python sdk.
I had a look at all the versions again (using python -m pip freeze):
azure-common==1.1.24
azure-graphrbac==0.61.1
azure-mgmt-authorization==0.60.0
azure-mgmt-containerregistry==2.8.0
azure-mgmt-keyvault==2.0.0
azure-mgmt-resource==7.0.0
azure-mgmt-storage==7.1.0
azureml==0.2.7
azureml-automl-core==1.0.83.1
azureml-core==1.0.69
azureml-dataprep==1.1.36
azureml-dataprep-native==13.2.0
azureml-pipeline==1.0.69
azureml-pipeline-core==1.0.69
azureml-pipeline-steps==1.0.69
azureml-sdk==1.0.69
azureml-telemetry==1.0.69
azureml-train==1.0.69
azureml-train-automl-client==1.0.83
azureml-train-core==1.0.69
azureml-train-restclients-hyperdrive==1.0.69
As I was surprised to see all the 1.0.69 versions, instead of the 1.0.83 versions, I re-installed the azureml python sdk using:
azuremlsdk::install_azureml(version = "1.0.83")
This worked, in the sense that indeed all versions are now 1.0.83:
azure-common==1.1.24
azure-graphrbac==0.61.1
azure-mgmt-authorization==0.60.0
azure-mgmt-containerregistry==2.8.0
azure-mgmt-keyvault==2.0.0
azure-mgmt-resource==7.0.0
azure-mgmt-storage==7.1.0
azureml==0.2.7
azureml-automl-core==1.0.83.1
azureml-core==1.0.83
azureml-dataprep==1.1.36
azureml-dataprep-native==13.2.0
azureml-pipeline==1.0.83
azureml-pipeline-core==1.0.83
azureml-pipeline-steps==1.0.83
azureml-sdk==1.0.83
azureml-telemetry==1.0.83
azureml-train==1.0.83
azureml-train-automl-client==1.0.83
azureml-train-core==1.0.83
azureml-train-restclients-hyperdrive==1.0.83
But still... I get the error with the missing core. I get it both when running:
library(azuremlsdk)
get_current_run()
and also when running:
library(azuremlsdk)
existing_ws <- get_workspace(name = name,
subscription_id = subscription_id,
resource_group)
Note that the first time running this code after starting up RStudio, I get the error:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: module 'azureml' has no attribute '_base_sdk_common'
And every time after that I get this error:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: module 'azureml' has no attribute 'core'
Any help would be much appreciated!
This issue was introduced by the latest reticulate 1.14 release, in which reticulate would create a default r-reticulate conda environment. Since Azure ML was installing the python SDK in an environment named r-azureml, the r-reticulate environment used by reticulate was missing the python SDK. A fix for this issue was addressed in a PR and has been merged into master. Please install from GitHub for now if you have reticulate version 1.14 and are running into this issue. We will be releasing an update to CRAN shortly.
I seemed to have fixed the issue by specifically installing the python package azureml AND azureml.core:
python -m pip install azureml
and then...
python -m pip install azureml.core
I did this for the Conda version that was called by R (r-reticulate). It's a bit odd to not be able to use the Conda environment 'r-azureml' without R switching back to 'r-reticulate', but ah well... at least I don't get my 'azureml' has no attribute 'core' anymore.

7: [unixODBC][DataDirect][ODBC 20101 driver]6015 error

For our application we have planned to use the Progress Data Direct ODBC driver for oracle. So i have downloaded the EVAL version and installed it. Our application servers are running in the Linux environment.
After installing the EVAL version i have tested the sample code provided by them. I have configured the ODBC.INI and ODBCINST.INI properly.
Tested the DSN connection successfully with the sample program provided by DataDirect Progress.
Then i started using the same for my application Lib LD path set properly ODBC , ODBCINST variables are properly set.
when i try to bring up my servers i got the below error message
7: [unixODBC][DataDirect][ODBC 20101 driver]6015
In this message i'm not getting the message description , only i got the error code which is 6015
How to get the error message for this code 6015 ?
Any help on this?
Due to the older version of driver got the error , so installed newer version and it got resolved.

Reading a access database (mdb) in 64 bit in R

I have a database and I need to read that in R. I found some packages such as Hmisc and RODBC which have the functions to do that. I am using windows and was not able to use Hmisc because you need to have mdb-tools package and I found no tutorial or way to install mdb-tools on windows.
Now, I was trying to start with RODBC. I found this question "How to connect R with Access database in 64-bit Window?" which shows how to have a connection in windows. I tried to use the command similar to what was accepted answer in that question.
odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=E:/Projects\Newdata/2013 Database/Data/pgdabc_SW.mdb")
It gives the following error :
1: In odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)}, DBQ=E:/Projects\Newdata/2013 Database/Data/pgdabc_SW.mdb") :
[RODBC] ERROR: state 01S00, code 0, message [Microsoft][ODBC Driver Manager] Invalid connection string attribute
2: In odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)}, DBQ=E:/Projects\Newdata/2013 Database/Data/pgdabc_SW.mdb") :
ODBC connection failed
I am not sure how to check and start diagnosing what's going on here. I went to administrative tools and checked the options on "Data Sources (ODBC)". . I changed the target to sysWOW.
Then I created a new data source as follows:
I am not sure if I need to select database or not. I found Brian Ripley's http://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf RODBC tutorial but still I am not able to make it work.
This works fine for me & might work for you, too:
require(RODBC)
conn <- odbcConnectAccess2007(path.expand("~/Database.accdb"))
subset(sqlTables(conn), TABLE_TYPE == "TABLE")
df <- sqlFetch(conn, "Table1")
close(conn)
My sessionInfo():
# R version 3.1.1 (2014-07-10)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
#
# other attached packages:
# [1] RODBC_1.3-10
#
# loaded via a namespace (and not attached):
# [1] tools_3.1.1
I have had issues with this (trying to query Access 32bit from R 64bit) from a long time. I think it has been fixed in windows 10.
I made a kludge by modifying something I found in this post:
How to connect R with Access database in 64-bit Window?
I made a function that saves a script (which in turn connects to the database and saves the result of the query), run it using R32, and load the data into the R64 work environment.
I prepared it for Access 2007, but something analogue could be done for Access2003 (just using odbcConnectAccess instead of odbcConnectAccess2007) or other 32 bit databases
MysqlQueryAccess2007<-function(filename,query){
tempdir=gsub('\\\\','/',tempdir())
txt<-paste("if (!'RODBC' %in% installed.packages()) install.packages('RODBC')
require(RODBC)
channel<-odbcConnectAccess2007('",filename,"')
data<-sqlQuery(channel,\"",query,"\")
save(data,file=paste('",tempdir,"','tempRODBCquery.Rdata',sep='/'))
close(channel)",sep="")
writeLines(txt,con=paste(tempdir,'RODBCscripttemp.r',sep='/')->tempscript)
system(paste0(Sys.getenv("R_HOME"), "/bin/i386/Rscript.exe ",tempscript))
tt<-get(load(paste(tempdir,'tempRODBCquery.Rdata',sep='/')))
return(tt)
}
Then you only have to do the queries this way:
dat<-MysqlQueryAccess2007("samplefile.accdb","SELECT TOP 5 * FROM TableI")
Have been trying to figure it out for a while myself.
Solution given in the accepted answer here
Reading data from 32-bit Access db using 64-bit R, credits to #erg,
as well as here
How to connect R with Access database in 64-bit Window?, credits to #JATT.
The bottom line:
Install 64-bit Microsoft Access drivers https://www.microsoft.com/en-us/download/details.aspx?id=54920
Setup appropriate System DSN in ODBC Data Sources (64-bit)
In R 64-bit read .mdb file by using odbc package: dbConnect(odbc(), 'your_64bit_dsn').

Error in installing Virtuoso Conductor on CentOS

I installed the latest version of Virtuoso using yum on CentOs. I was able to successfully do that first time. However,when I restarted the virtuoso server after uploading a dataset/CSV file, I am not seeing the 'conductor tab' in the webUI.
I thought something went wrong - and tried to do a clean install. But I have somehow managed to loose conductor completely this time. Below is the log snippet of virtuoso-t.
10:41:00 INFO: PL LOG: Installing Virtuoso Conductor version 1.00.8727 (DAV)
10:41:00 INFO: Checkpoint started
10:41:00 INFO: Checkpoint finished, log reused
10:41:00 INFO: PL LOG: VAD_INSTALL: Please update server version (FATAL)
10:41:00 INFO: PL LOG: Errors where detected during installation of "Virtuoso Conductor".
You report you "installed the latest version of Virtuoso using yum" -- but what version did you actually get? We provide a CentOS-specific guide which may now be outdated if someone has produced a yum package -- but that package may also be outdated.
Please check the version you have actually installed (output of virtuoso-t -? gives the best version string), and be sure it is at least 6.1.8 (if Virtuoso v6) or 7.2.2 (if Virtuoso v7). If not, I would suggest a clean rebuild/reinstall, following our instructions, based on the latest source from GitHub.
For future, questions specifically regarding Virtuoso are often best raised on the public Virtuoso Users mailing list, the public OpenLink Support Forums, or through a confidential Support Case. ObDisclaimer: I work for OpenLink Software, producer of Virtuoso.

rgdal error when connecting to postgres

I'm working with a Mac Os 10.9.2 and a R version 3.0.2.
I used dbDriver() and dbConnect() to initiate the connection to my database. Next, I tried to connect to my postgres database using
c = readOGR("PG:dbname=OB", layer="geo.countries")
This does not work, and always returns a "Cannot open file" error.
I understood from https://stat.ethz.ch/pipermail/r-sig-geo/2010-January/007519.html that the reason for this is the absence of a driver for PostgreSQL. As can be seen by using the command ogrDrivers()
Does anybody can help me on how to install the driver? Or how I can make this work? Any help is much appreciated!
Thanks!
In the absence of the right driver, gdal/ogr usually throws and error like
Unable to find driver PostgreSQL
First, make sure that the database and layer exist. If it's true that the driver for Postgres isn't installed, you'll have to re-install gdal. Using homebrew:
brew uninstall gdal
brew install gdal --with-postgresql
See also this question.
If you are really sure that gdal is properly installed, make sure that your dns is fully specified (it has more parameters than dbname)
dsn="PG:dbname=DB host=HOST user=USER password=PSSWD port=5432"
Moreover, if your table contains more than one spatial columns (layers), you have to specify the one you want:
layer = "DB.TABLE(YOUR_SPATIAL_COLUMN)"
Took me a while to find out. But it was obvious after calling function
ogrListLayers()
It works for me. Just one issue, if you have some raster column in you table, it will not be excluded (as all other layers/spatial columns). Instead, it will be loaded into spatialobject#data dataframe as text column. Quite annoying in case of big rasters. I have posted question for this.

Resources