import pyodbc
def connect_to_sql():
"""
Connect to SQL Server.
Returns
-------
pyodbc.Connection
Connection to SQL Server.
"""
#connect to SQL Server
conn = pyodbc.connect('Driver={SQL Server};'
'Server=localhost;'
'Database=test;'
'Trusted_Connection=yes;')
#return the connection
return conn
#example
conn = connect_to_sql()
#output
print(conn) #<pyodbc.Connection object at 0x7f8b8d9c0e10>
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)