Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import pyodbc
  2. driver = 'SQL Server'
  3. server = '**server-name**'
  4. db1 = 'CorpApps'
  5. tcon = 'yes'
  6. uname = 'jnichol3'
  7. pword = '**my-password**'
  8.  
  9. cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=db1;UID=uname;PWD=pword;Trusted_Connection=yes')
  10. cursor = cnxn.cursor()
  11. cursor.execute("select * from appaudit_q32013")
  12. rows = cursor.fetchall()
  13. for row in rows:
  14. print row
  15.  
  16. Traceback (most recent call last):
  17. File "pyodbc_test.py", line 9, in <module>
  18. cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=db1;UID=uname;PWD=pword;Trusted_Connection=yes')
  19. 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)')
  20.  
  21. cnxn = pyodbc.connect(driver='{SQL Server}', host=server, database=db1,
  22. trusted_connection=tcon, user=uname, password=pword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement