1

I am trying to use kinit method inside a Python console and its not working. This is what I am trying in the macOS terminal. I've already generated the Keytab file

kinit ABC@XXXX.ORG -k -t xyz.keytab

and then invoke the python command line and then try to execute the pyodbc command

db2=pyodbc.connect(r'driver={ODBC Driver 17 for SQL Server};server=host1;database=test_Datamart;trusted_conection=yes;')

When I just give the sqlcmd thing on terminal I was able to connect to sqlserver

sqlcmd -S xxxx.org,5432 -E -d test_Datamart

but when I invoke the python and try to connect using pyodbc, its throwing an error.

 pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''. (18456) (SQLDriverConnect)")

Any suggestions please??

Bharat Guda
  • 117
  • 3
  • 14

1 Answers1

0

Just changing the single quotes to double quotes worked for me!

db2=pyodbc.connect"driver={ODBC Driver 17 for SQL Server};server=host1;database=test_Datamart;trusted_conection=yes;")
Bharat Guda
  • 117
  • 3
  • 14