I am trying to create an alternative to Reader "to read data from an Azure SQL database using the Execute python script module in Azure ML . By doing this, I am trying to connect to Azure Sql using the pyodbc library. Here is my code:
def azureml_main(dataframe1 = None, dataframe2 = None): import pyodbc import pandas as pd conn = pyodbc.connect('DRIVER={SQL Server}; SERVER=server.database.windows.net; DATABASE=db_name; UID=user; PWD=Password') SQLCommand = ('''select * from table1 ''') data_frame = pd.read_sql(SQLCommand, conn) return data_frame,
also tried using a different driver name: {SQL Server 11.0 Native Client}
Here is the error I get:
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Does anyone know which driver should I use?
to make sure I tried "{SQL Server}", "{SQL Server Native Client 11.0}" and "{SQL Server Native Client 10.0}" and got the same error
I also tried a different format:
conn = pyodbc.connect('DRIVER={SQL Server}; SERVER=server.database.windows.net; DATABASE=db_name; user=user@server ; password=Password')
and
conn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0}; SERVER=server.database.windows.net; DATABASE=db_name; user=user@server ; password=Password')
source share