Skip to content

lookup SQL Server instance port from Linux client

License

Notifications You must be signed in to change notification settings

lgonzalezsa/sqlserverport

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlserverport

A simple Python module to query the SQL Browser service for the port number of a SQL Server instance. The Linux implementation of Microsoft's "ODBC Driver xx for SQL Server" is (still) unable to resolve instance names, so Windows users can just do

import pyodbc
serverspec = r'myserver\SQLEXPRESS'
conn = pyodbc.connect('DRIVER=ODBC Driver 13 for SQL Server;SERVER={};...'.format(serverspec))

but that won't work on Linux. This module lets us do

import pyodbc
import sqlserverport
servername = 'myserver'
serverspec = '{0},{1}'.format(
    servername,
    sqlserverport.lookup(servername, 'SQLEXPRESS'))
conn = pyodbc.connect('DRIVER=ODBC Driver 13 for SQL Server;SERVER={};...'.format(serverspec))

About

lookup SQL Server instance port from Linux client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%