Error connecting to mongoDB using Mongolite - r

I'm having issues connecting to my MongoDB via Mongolite, and I'm not sure if it is an issue on my side, or if I need to use a different package to connect to the database. Please keep in mind that I cannot change the software being run by the MongoDB server, and I am a novice when it comes to all of this, so it could just be a silly error on my part.
I've run the following code:
m <- mongo(collection = "test", url="mongodb://22.92.59.149:27017")
As far as I can tell from the Mongolite tutorial (https://jeroen.github.io/mongolite/), this is the correct syntax to connect to the database, but I'm not 100% sure. Regardless, I get the following error:
Error: Server at 22.92.59.149:27017 reports wire version 2,
but this version of libmongoc requires at least 3 (MongoDB 3.0)
From what I can tell, this means that mongolite won't work with my database. If that is the case, what other package should I try to use to connect, or if it is not the issue what am I doing wrong?
Thanks in advance!

As the message says, there is a mismatch between versions of the client and the server.
More precisely, mongolite relies on a more general driver written in C, libmongoc, and it seems the version automatically installed by the install.packages("mongolite") statement is too recent towards the server's version.
If you can't change anything server-side, maybe you could try to manually install an older version of libmongoc before installing mongolite, but I'm not confident about the compatibility with that R package afterwards.
Maybe you can use RMongo, an older and archived package to interact with Mongo in R, but I'm afraid what you're going to develop won't be stable in further R versions.
I'd rather recommend you to look at the problem server side.

Related

R Oracle connect via DBI::dbDriver("Oracle") throws error

I try to do a simple connect to an Oracle database via DBI and ROracle package following instructions from R to Oracle Database Connectivity: Use ROracle for both Performance and Scalability.
When I test the connection via Windows7 > ODBC Data Source Administrator (32bit), the connection is successful. It uses the installed Oracle client OraClient11g_home1 which resides in C:\oracle\Client112_32. ORACLE_HOME environment variable is set to C:\oracle\Client112_32.
I am guessing it may be connected to some 32bit/64bit issue? But even after quite some research I did not find any solution. I also tried running the same in R 32bit but fails as well. BTW, the connection via SQL Developer is also successful.
drv <- DBI::dbDriver("Oracle")
#>Error: Couldn't find driver Oracle. Looked in:
#>* global namespace
#>* in package called Oracle
#>* in package called ROracle
I've had this issue as well. I found that loading the ROracle library beforehand fixes the problem.
library("ROracle")
drv <- DBI::dbDriver("Oracle")
I don't know why though.
Building on user11227405 answer: it is actually enough to load ROracle without attaching it on the search path; library() does both instead:
loadNamespace("ROracle")
drv <- DBI::dbDriver("Oracle")
that might be preferred e.g. in packages, where changing the search path should be avoided

"Invalid BXL stream" in MS-SQL server while executing R scripts

I am executing an R script as ms-sql stored procedure. I'm trying to use the "geosphere" package, however when I execute the stored procedure, I'm getting the error "Invalid BXL stream" and the execution halts. The package is already installed on the machine and simply loading the package causes this error i.e library("geosphere") causes the error.
I can however, use this package independently with R Studio, so there doesn't seem to be any issue with the package.
I know this question is dated but I've run into the same issue multiple times so I wanted to leave my results here.
What I've found in using sp_execute_external_script to run R and Python scripts in MS-SQL 2016/17 is that the BXL error comes for 2 different reasons
Bad data types - Often, SQL doesn't understand the data types being sent out of the script. Usually explicitly casting the data as a certain datatype helps here.
Bad package configuration - Certain packages in the R and Anaconda distributions don't sync well with the stored procedure since the database blocks certain dependencies in these packages. Try reinstalling the package in the SQL installed instance of R or Python.
It seems that your problem falls in the latter category. I hope that helped!
Had a similar issue today but with a different package. Getting "invalid BXL stream from MSSQL stored procedure. However, i found that If i opened up Rterm.exe and typed the command 'require(packagename)' then Rterm crashes with "Rterm frontend has stopped working". This looks like a memory issue - which has also been suggested causes the "invalid BXL stream" error.
However, my issue turned out to be the fact that the dependencies for the packages had not been installed correctly (perhaps you are working through a proxy?).
I basically removed all the library packages that had been created when I first installed the problem package and did a install.packages("packagename"). All started working!
Apologies - just noticed that you stated that the package worked independently with R studio - this is probably an issue with R Memory allocation with SQL - See http://henkvandervalk.com/introducing-microsoft-sql-server-2016-r-services

Hive connector in R / Rstudio

Does anybody knows if it's possible to interface Hadoop with R / Rstudio ? If yes, HOW?
I have some hive's table and I'd like to accès them with R / Rstudio and within 'shiny' make a visual restitution (graphs etc...).
I would appreciate any help (ideas, code examples ...).
Try the package dplyr.hive.spark. The docs are still a bit more geared towards spark, but I tested it against Hive with the latest HDP sandbox and things were going smoothly. If you give it a try please report any problems.
If you just want to access hive tables on HDFS, you can use the RJDBC package and a JDBC connection (explained here: https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC). Then you can use RJDBC just like you would for a relational database except that it might launch some map/reduce jobs on your cluster to execute.

Can not tnsping but can sqlplus connect

I have a question hopefully someone could explain it to me. I have an Oracle 11g installed properly on the server. From a workstation, I have installed the oracle client which tnsname.ora pointed to the Oracle database. I can ping to the server where oracle db was installed. I can sqlplus connect to the database and I can even connect to the database programmatically using C#. However, I can not tnsping to it. I got error Message 3511 not found when trying to do so. So my question is: in what scenario tnsping is used and how do I make tnsping works? In other word, if my tnsping does not work but I still can connect to the database programmatically using C#, what are the concerns that I should be worrying about? I am new to Oracle.. Thanks!
I have tried to do the following actions without success although they are the most popular answers to similar scenario similar to mine.
1) Set Oracle_Sid to my oracle sid
2) Set Oracle_Home to my oracle home directory
What I did to solve the issue:
1) Uninstall oracle client
2) Reinstall the oracle client with the newest version 11.2.xx.
I believe, re-installing the oracle client of earlier version would just work as well.
However, since I have to re-install the client, I might want to get the newest version.
The cause is probably improper installation at the first time as we have an disk image of pre-installed application to automatically prep a new computer.
Not able tnsping does not seem to impede with other Oracle operations (at least not that I know of).
If someone knows what is the limitation of not able to tnsping but can sqlplus connect, ping... , I would appreciate if you could share.
Either your $Oracle_Home value is not set or your default sid is not set in $ORACLE_SID
Try this :
set ORACLE_SID=mysid
export ORACLE_SID
tnsping mysid
and see what it comes back with.

Migration from legacy version to newer version or MySQL

I recently dug up a very old SQL Anywhere database. I have it installed and it kind of works, its only the distributed side of the data, so everything's running via dbeng50 and ODBC.
I would like to migrate this data to MySQL. Is there a way to do this? I attempted to view the data using an ODBC tool but I kept getting error messages saying the ODBC driver doesn't support the version of ODBC behavior.
I guess the database is too old (it's from 1997) - that put's at it SQL Anywhere version 5.
Its also difficult to find the old SQL tools that would help me access these.
Is it possible to use the .db file with a newer version?
Any help or guidance at all would be appreciated.

Resources