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
New Contributor II
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
New Contributor II

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