Skip to content
Advertisement

Python – Using pyodbc to connect to remote server using info from Excel data connection

I have an excel (albeit, one that’s on our company server) that has a data connection to our SQL database so we can make nice pivot tables.

I would like to get that data into python (on my local computer) so I can do some faster analysis.

I have installed pyodbc.

Here is the “connection string” from the excel:

JavaScript

and now I have the python script:

JavaScript

and I am getting errors saying that SQL Server does not exist or access denied.

Any help is greatly appreciated.

Advertisement

Answer

You don’t need the single quotes around each field, and may need a port… Try something like this:

JavaScript

Good luck!

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