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: 

Connection to Azure SQL Server: ODBC Driver 18 for SQL Server

js54123875
New Contributor III

Task:

Setup connection to Azure SQL Server.

A couple things have changed...

*We've started using Unity Catalog, so need Unity Catalog -enabled clusters

*Legacy init scripts have been deprecated, and this is how we had our pyodbc setup, etc. defined.

Code:

import pyodbc
def build_odbc_connection(dbserver, dbname, username, pwd):
  conn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER='+dbserver+';DATABASE='+dbname+';ENCRYPT=yes;UID='+username+';PWD='+ pwd)
  return conn
 
def execute_azsql_query(sqlquery):
  conn = build_odbc_connection(sec_SourceServer, sec_SourceDatabase,sec_SinkAzSqlAppID,sec_SinkAzSqlSecret)
  df = pd.read_sql(sqlquery,conn)
  conn.close()
  return df
 
execute_azsql_query('select * from dbo.client')

Error:

('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 18 for SQL Server' : file not found (0) (SQLDriverConnect)")

What am I missing here? Thanks!

4 REPLIES 4

Anonymous
Not applicable

Hi @Jennette Shepard​ 

Hope everything is going great.

Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best so that other members can find the solution more quickly? If not, please tell us so we can help you. 

Cheers!

js54123875
New Contributor III

Thanks for checking in. Yes the driver is not installed, but I'm not sure the current correct way to install

diego_poggioli
Contributor

Hi @js54123875 did you manage to find a solution for this? I'm facing a similar problem.

Thanks

Diego

Hi @Jodie - We're using this jdbc driver to connect Query SQL Server with Databricks | Databricks on AWS

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