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 17 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 17 for SQL Server;SERVER={};...'.format(serverspec))
Installing
pip install sqlserverport
Example
# example.py
import sqlserverport
# test data
server_name = "192.168.0.103"
instance_name = "SQLEXPRESS"
try:
result = r"Instance {0}\{1} is listening on port {2}.".format(
server_name,
instance_name,
sqlserverport.lookup(server_name, instance_name),
)
except sqlserverport.BrowserError as err:
result = err.message
except sqlserverport.NoTcpError as err:
result = err.message
print(result)
Metadata
Release files for sqlserverport 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlserverport-1.0.1.tar.gz | 3.4 kB | Without provenance | Details for sqlserverport-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlserverport-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sqlserverport-1.0.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / sqlserverport-1.0.1.tar.gz
| Download URL | sqlserverport-1.0.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48ecae8514d2585070184b21c05c9df0e1121f685a95f961b7c115fa1503a195
|
|
BLAKE2b-256 checksum How to use checksums |
d485fba3397080fc9d05685266291fb05d3269b044a0108adb11c6d016b92116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Release files / sqlserverport-1.0.1-py3-none-any.whl
| Download URL | sqlserverport-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa425ae398929fc464eb9c3c56b88b9758b1fdd70d35652e1cc46999509fd559
|
|
BLAKE2b-256 checksum How to use checksums |
c1ce3b692ffaa2aa906c1dab6816d50a384b5cdf0cbc53f802bfd6d04f926643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Security for sqlserverport 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.