Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyodbc
- driver = 'SQL Server'
- server = '**server-name**'
- db1 = 'CorpApps'
- tcon = 'yes'
- uname = 'jnichol3'
- pword = '**my-password**'
- cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=db1;UID=uname;PWD=pword;Trusted_Connection=yes')
- cursor = cnxn.cursor()
- cursor.execute("select * from appaudit_q32013")
- rows = cursor.fetchall()
- for row in rows:
- print row
- Traceback (most recent call last):
- File "pyodbc_test.py", line 9, in <module>
- cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=db1;UID=uname;PWD=pword;Trusted_Connection=yes')
- pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)')
- cnxn = pyodbc.connect(driver='{SQL Server}', host=server, database=db1,
- trusted_connection=tcon, user=uname, password=pword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement