git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pyodbc -> MS-SQL Server Named Instance ?


On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
> I am trying to connect to a Named Instance on an MS-SQL server using
> pyODBC.
> 
> The ODBC driver works, as I can connection without issue to a non-
> named-instance SQL-Server used by another application.
> 
> What is the DSN (connection) string magick to connect to a named
> instance?
> 
> I can connect from my JDBC client (DbVisualizer) by specifying the
> instance name and port 1434.
> 
> 

This is what I use -

     conn = pyodbc.connect(
         driver='sql server',
         server=r'localhost\sqlexpress',
         database=self.database,
         user=self.user,
         password=self.pwd,
         trusted_connection=True)

SQL Server is running on the same host as my python program, so it may 
be a simpler setup than yours.

Frank Millman