Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Connexion MongoDB python

I have a problem connexion MongoDB by Python

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

Driver name : MongoDB Java Driver » 3.11.0-beta2

Code Python : import sys import json from java.sql import DriverManager from java.sql import Types import string sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ") from com.mongodb import * from com.mongodb.client.model import * from org.bson import * import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service") con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0 db = con_mdb.getDatabase("competition") cpt=0 for record in records: collection = db.getCollection("testcompetitions") document = Document() document.putAll(record.value['data']) collection.insertOne(document); stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;") stmt.setString(1,str(record.value['KEY'])) stmt.setString(2,"P" ) stmt.setString(3,record.value['FIN_TRAIT'] ) stmt.execute() con_ora.commit() stmt.close() con_ora.close()

Connexion MongoDB python

I have a problem connexion MongoDB by Python

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

Driver name : MongoDB Java Driver » 3.11.0-beta2

Code Python :

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service") con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0 db = con_mdb.getDatabase("competition") cpt=0 for record in records: collection = db.getCollection("testcompetitions") document = Document() document.putAll(record.value['data']) collection.insertOne(document); stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;") stmt.setString(1,str(record.value['KEY'])) stmt.setString(2,"P" ) stmt.setString(3,record.value['FIN_TRAIT'] ) stmt.execute() con_ora.commit() stmt.close() con_ora.close()

con_ora.close()

Connexion MongoDB python

I have a problem connexion MongoDB by Python

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

Driver name : MongoDB Java Driver » 3.11.0-beta2

Code Python :

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

Connexion Connecting to MongoDB pythonfrom Python

I have a problem connexion connecting to MongoDB by Pythonfrom Python.

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

Driver name : MongoDB Java Driver » 3.11.0-beta2 3.11.0-beta2

Code Python : code:

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

Connecting to MongoDB from Python

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

Python code:

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

UPDATED: I installedl the MongoDB and Oracle drivers on driver package also i remove sys.path.append on the code but i have the same problem

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
#sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

Connecting to MongoDB from Python

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

Python code:

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

UPDATED: I installedl the MongoDB and Oracle drivers on driver package also i remove sys.path.append on the code but i have the same problem

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
#sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

Connecting to MongoDB from Python

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

Python code:

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("MongoDB Java Driver » 3.11.0-beta2 ")
sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

UPDATED: I installedl the MongoDB and Oracle drivers on driver package also i remove sys.path.append on the code but i have the same problem

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
#sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

Connecting to MongoDB from Python

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

Python code:

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()

UPDATED: I installedl the MongoDB and Oracle drivers on driver package also i remove sys.path.append on the code but i have the same problem

import sys
import json
from java.sql import DriverManager
from java.sql import Types
import string
#sys.path.append("mongo-java-driver-3.11.0-beta2.jar")
from com.mongodb import *
from com.mongodb.client.model import *
from org.bson import *
import org.bson.Document as Document

con_ora = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.123.26)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=F2000Q)))", "FFF_RF2K", "FffqWeb*service")
con_mdb = MongoClient("FFF-MONQ-BCK01.fff.lan:27017")

con_ora.autoCommit=0
db = con_mdb.getDatabase("competition")
cpt=0
for record in records:
    collection = db.getCollection("testcompetitions")
    document = Document()
    document.putAll(record.value['data'])
    collection.insertOne(document);
    stmt = con_ora.prepareCall("begin FFF_RF2K.IO_TRAIT_F2K_MDB.Modification(?,?,?); end;")
    stmt.setString(1,str(record.value['KEY']))
    stmt.setString(2,"P" )
    stmt.setString(3,record.value['FIN_TRAIT'] )
    stmt.execute()
    con_ora.commit()
    stmt.close()
con_ora.close()