In this tutorial we will learn how we can connect to SQL server from Databricks. We will be using jdbc to connect SQL server instance into Data Bricks.
Please find below code to connect to sql server from Data Bricks.
HostName = "your sql server host name"
Port = "sql server port Default port is 1433"
DatabaseName = "Your Database Name"
#now create jdbc url for the server and Database
jdbc_url = "jdbc:sqlserver://{0}:{1};database={2}".format(HostName, Port, DatabaseName"
ConnectionProperties = {
"user": "UserName"
"password" : "Password"
"driver" : "com.microsoft.sqlserver.jdbc.SQLServereDriver"
}
#write a Data Frame Data into sql server
df.write.jdbc(jdbc_url, "Table Name", ConnectionProperties)
This is how we can read data from xml in Data Bricks.
Please let me know your question or feedback in comments.