0

I'm having trouble connecting to a MS SQL Server database via Python using pyODBC:

import pyodbc
conn = pyodbc.connect(('DRIVER={SQL Server};'
                       'SERVER=tmw-prod-lo\\SQL65;'
                       'DATABASE=TMWSuite;'
                       'UID=VENTURE\\acoop;'
                       'PWD=RaNdoM!'))

This results in:

InterfaceError: ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'VENTURE\\acoop'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'VENTURE\\acoop'. (18456)")

I'm pretty confident I've got all the parameters right and that I need to escape the backslashes in the server and username as above, correct? So it just looks like a permissions issue but I wanted to rule out any other issues first.

ACoop
  • 1
  • 4
  • I think it is pretty obvious from error message: `Login failed for user`. It seems like permission/ login/ password issue. – thor Jan 08 '19 at 20:09
  • Several questions: a) OS: Windows,Linux,other? b) Authenthification Mode: Windows or SQLServer? – Alex Yu Jan 08 '19 at 20:09
  • @thor - it's not so obvious. I suspect that `pyodbc` is trying to connect thru SQLServer Authentification and @ACoop provides Windows credentials – Alex Yu Jan 08 '19 at 20:12
  • @ACoop: can you connect using `sqlcmd`/`bcp`/`other cli` to SQLServer? – Alex Yu Jan 08 '19 at 20:14
  • Thanks everyone, yes this is on Windows, I was providing Windows credentials via which I'm able to connect using SQL Server Management Studio. IT set up a new account that works, there may have also been an issue with the backslash in my username (as the new one does not have one), but not sure. – ACoop Jan 10 '19 at 13:27

0 Answers0