Skip to content
Advertisement

Test Connection pyodbc (Python and SSMS)

I’m trying to follow some simple steps in this Microsoft doco but I can get it to connect.

What am I doing wrong?

JavaScript

This is the error message:

PS C:UsersNelson.Silva> &

JavaScript

Advertisement

Answer

You changed your code before posting. In the code block you say the connect line is

JavaScript

but in the exception block the line is:

JavaScript

The problem is not the connection. Your python code is invalid. Python is telling you that you haven’t closed one of your strings: SyntaxError: unterminated string literal (detected at line 7) It also gives you a convenient little ^ under where it thinks you haven’t closed a string. In the exception block its at the end of the ;PWD='+ password').

';PWD='+ password') should be ';PWD='+ password) (notice the lack of ‘ at the end of password)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement