cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

mongodb ingest data into databricks error

jeft
Visitor
spark = SparkSession.builder \
.appName("MongoDBToDatabricks") \
.config("spark.jars.packages", "org.mongodb.spark:mongo-spark-connector_2.12:10.4.0") \
.config("spark.mongodb.read.connection.uri", mongodb_uri) \
.config("spark.mongodb.write.connection.uri", mongodb_uri) \
.getOrCreate()

# Read data from MongoDB
df = spark.read \
.format("com.mongodb.spark.sql.connector.MongoTableProvider") \
.option("database", database_name) \
.option("collection", collection_name) \
.option("readPreference", "primary") \
.load()

df.printSchema()
1 REPLY 1

jeft
Visitor

Screenshot 2024-11-04 at 4.34.15 PM.png

 it shows maximun number of retires has been exceeded. i have no idea why it couldnt connect as i able to telnet to mongoDB

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group