Skip to content

Commit e9be253

Browse files
authored
Merge pull request pymssql#446 from sietse/example-windows-auth
docs: Add example: connect using Windows Authentication
2 parents 5c5737a + 19f4281 commit e9be253

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/pymssql_examples.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ Basic features (strict DB-API compliance)
4444

4545
conn.close()
4646

47+
Connecting using Windows Authentication
48+
=======================================
49+
50+
When connecting using Windows Authentication, this is how to combine the
51+
database's hostname and instance name, and the Active Directory/Windows Domain
52+
name and the username. This example uses
53+
`raw strings <https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals>`_
54+
(``r'...'``) for the strings that contain a backslash.
55+
56+
::
57+
58+
conn = pymssql.connect(
59+
host=r'dbhostname\myinstance',
60+
user=r'companydomain\username',
61+
password=PASSWORD,
62+
database='DatabaseOfInterest'
63+
)
64+
4765
Iterating through results
4866
=========================
4967

0 commit comments

Comments
 (0)