SHARE
TWEET

Untitled

a guest Mar 20th, 2017 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1210   | 20/03/17 - 14:05:33 | sudo su
  2.  1211   | 20/03/17 - 14:06:25 | sudo apt-get update
  3.  1220   | 20/03/17 - 14:11:44 | sudo apt-get install msodbcsql
  4.  1221   | 20/03/17 - 14:13:13 | sudo apt-get install mssql-tools
  5.  1222   | 20/03/17 - 14:13:28 | sudo apt-get install unixodbc-dev-utf16
  6.  1224   | 20/03/17 - 14:15:35 | sudo apt-get install unixODBC-devel
  7.  1225   | 20/03/17 - 14:15:54 | sudo apt-get install unixodbc-dev
  8.  1226   | 20/03/17 - 14:16:28 | sudo apt-get install gcc-c++
  9.  1227   | 20/03/17 - 14:16:36 | sudo apt-get install python-devel
  10.  1228   | 20/03/17 - 14:16:59 | sudo pip install pyodbc==3.1.1
  11.  
  12.  1231   | 20/03/17 - 14:17:32 | vim mssql.py
  13.  
  14.  
  15.  import pyodbc
  16. import sys
  17.  
  18. server = ''
  19. database = ''
  20. username = ''
  21. password = ''
  22. driver= '{ODBC Driver 13 for SQL Server}'
  23.  
  24. cnxn = pyodbc.connect('DRIVER='+driver+';PORT=1433;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password)
  25. cursor = cnxn.cursor()
  26.  
  27. cursor.execute(sys.argv[1])
  28.  
  29. row = cursor.fetchone()
  30.  
  31. while row:
  32.     print str(row[0]) + " " + str(row[1]) + " " + str(row[2])
  33.     row = cursor.fetchone()
  34.  
  35.  
  36.  
  37.  1235   | 20/03/17 - 14:20:46 | python mssql.py 'select * from table'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top