06-09-2023 02:18 PM
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!
06-15-2023 05:17 AM
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.
06-16-2023 12:20 AM
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!
06-16-2023 11:00 AM
Thanks for checking in. Yes the driver is not installed, but I'm not sure the current correct way to install
10-12-2023 12:21 AM
10-13-2023 12:10 PM
Hi @Jodie - We're using this jdbc driver to connect Query SQL Server with Databricks | Databricks on AWS
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