cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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!

5 REPLIES 5

Kaniz
Community Manager
Community Manager

Hi @Jennette Shepard​, The error message you provided indicates that the ODBC driver named ’ODBC Driver 18 for SQL Server is not found or cannot be opened. This error commonly occurs when the required driver files are missing or the driver is not installed correctly.

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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.