Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
gianpaolo
Level IV

help with R and mongo_db connection

hello community

i'm trying to connect on MongoDb through R interface by JSL script

i need to pass this strings

Names Default To Here( 1 );

RConnection = R Connect();

rc = RConnection << Submit("

library(mongolite)

m <- mongo(collection = "Param", db = "DbParam", url = "mongodb://ailyxxxx01a:27017/DbParam")

d <- m$find('{"\"FLDLOT" : "\""xxxxxx.000\""}')

:);

but i got sintax errors 

how i can pass red strings correcty into code?

 

 

 

thanks in advance

Gianpaolo

Gianpaolo Polsinelli
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
gianpaolo
Level IV

Re: help with R and mongo_db connection

I solved it by myself:

the issue was related to sintax error introduced by "  into R code

need to use escape characters because  to substitute  " with  \!"   

R Init( ); 

R Submit(

library(mongolite)

m <- mongo(collection = \!"ColParamLot\!", db = \!"DbaLfoundryParam\!", url = \!"mongodb://ailymsmdb01a:27017/DbaLfoundryParam\!")

d <- m$find('{\!"FLDLOT\!" : \!"8588679.009\!"}')

");

R Term();

 

Gianpaolo Polsinelli

View solution in original post

5 REPLIES 5
Highlighted
uday_guntupalli
Level VIII

Re: help with R and mongo_db connection

@gianpaolo
              Were you able to successfully connect to MongoDB using R outside JMP ? I would suggest you to share your syntax errors as well to provide the community a better insight into what your problems might be 

Best
Uday
Highlighted
gianpaolo
Level IV

Re: help with R and mongo_db connection

in red below the error

 

Unexpected "ColParamLot". Perhaps there is a missing "," or ")".

Trying to parse arguments of function "Submit".

Line 12 Column 27: m <- mongo(collection = \"►"ColParamLot""\, db = \"

 

 

Gianpaolo Polsinelli
Highlighted
uday_guntupalli
Level VIII

Re: help with R and mongo_db connection

@gianpaolo
   Were you able to connect to mongodb using just R outside JMP ?
   
   Additionally, look at this. I don't have mongodb so - cannot replicate the error .

 

https://datascienceplus.com/using-mongodb-with-r/ 

Best
Uday
Highlighted
gianpaolo
Level IV

Re: help with R and mongo_db connection

the code work well.... i did it with R and i obtain the data

library(mongolite)

m <- mongo(collection = "Param", db = "DbParam", url = "mongodb://ailyxxxx01a:27017/DbParam")

d <- m$find('{"\"FLDLOT" : "\""xxxxxx.000\""}')

 

 

so.. is the JSL script that has sintax error.... i suppose becasue this " "  characters 

Gianpaolo Polsinelli
Highlighted
gianpaolo
Level IV

Re: help with R and mongo_db connection

I solved it by myself:

the issue was related to sintax error introduced by "  into R code

need to use escape characters because  to substitute  " with  \!"   

R Init( ); 

R Submit(

library(mongolite)

m <- mongo(collection = \!"ColParamLot\!", db = \!"DbaLfoundryParam\!", url = \!"mongodb://ailymsmdb01a:27017/DbaLfoundryParam\!")

d <- m$find('{\!"FLDLOT\!" : \!"8588679.009\!"}')

");

R Term();

 

Gianpaolo Polsinelli

View solution in original post

Article Labels

    There are no labels assigned to this post.