Ask Your Question
1

Connecting to MongoDB from Python

asked 2019-04-30 02:56:37 -0500

aimad.goussa@gmail.com gravatar image

updated 2019-05-27 03:31:58 -0500

I have a problem connecting to MongoDB from Python.

Problem : No module named mongodb in <script> at line number 9

Driver name : MongoDB Java Driver » 3.11.0-beta2

Link Oracle: /opt/cloudera/parcels/STREAMSETS_DATACOLLECTOR-3.8.1/streamsets-libs-extras/streamsets-datacollector-jdbc-lib/lib/ojdbc8.jar

Link mongoDB: /opt/cloudera/parcels/STREAMSETS_DATACOLLECTOR-3.8.1/streamsets-libs-extras/streamsets-datacollector-jython_2_7-lib/lib/mongo-java-driver-3.11.0-beta2.jar

edit retag flag offensive close merge delete

Comments

Is it the exact same error message? Can you verify which directory on the disk contains the Oracle and Mongo DB drivers? Please edit your question rather than creating an answer.

metadaddy gravatar imagemetadaddy ( 2019-04-30 05:15:17 -0500 )edit

You need to install the Oracle lib for the Jython stage library as well as the JDBC. The stage libraries are isolated, so any drivers need to be installed again for each place you need to use them

metadaddy gravatar imagemetadaddy ( 2019-04-30 09:11:02 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2019-05-07 17:24:39 -0500

iamontheinet gravatar image

Hi!

Also refer to this https://ask.streamsets.com/question/4... to see how you can connect to MongoDB and execute queries from Jython Evaluator.

Cheers, Dash

edit flag offensive delete link more
0

answered 2019-04-30 03:39:27 -0500

metadaddy gravatar image

You need to use Package Manager to install the MongoDB and Oracle drivers for the Jython stage lib:

image description

You must also remove the sys.path.append call from your code.

The blog entry Calling External Java Code from Script Evaluators has some examples.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-04-30 02:56:37 -0500

Seen: 773 times

Last updated: May 27