Ask Your Question

Connecting to MongoDB from Python

asked 2019-04-30 02:56:37 -0600 gravatar image

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

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


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 -0600 )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 -0600 )edit

2 Answers

Sort by » oldest newest most voted

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

iamontheinet gravatar image


Also refer to this to see how you can connect to MongoDB and execute queries from Jython Evaluator.

Cheers, Dash

edit flag offensive delete link more

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

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


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

Seen: 1,032 times

Last updated: May 27 '19