Creating a table on a remote db from a databricks notebook using jdbc

33 Views Asked by At

I'm able to connect from databricks to the db and run queries on it using

query = "select count(1) c from dbo.my_table"
 
df = spark.read.format(
  "jdbc"
  ).option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  ).option("url", url
  ).option("authentication", 'ActiveDirectoryServicePrincipal'
  ).option("AADSecurePrincipalId", id_from_secret
  ).option("AADSecurePrincipalSecret", pw_from_secred
  ).option("database", database
  ).option("encrypt", "true"
  ).option("query", query).load()

How do I edit this code to run "create table dbo.my_new_table ({columns})"?

0

There are 0 best solutions below