1 – Aşağıdaki komutları çalıştrıyoruz. En alttaki satirda hata verirse “pip” paketini kuruyoruz (sitede nasıl kurulduğu vardır).
yum install unixODBC unixODBC-devel
yum install gcc-c++
yum install python-devel
pip install pyodbc
2 – Python ile mssql db ye baglantinin test edilmesi;
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import pyodbc
################## TANIMLAR #####################
dsn = 'mssql_server'
user = 'db_username'
password = 'db_password'
database = 'MXXXXXXS'
################## TANIMLAR #####################
def kullanici_liste():
con_string = 'DSN=%s;UID=%s;PWD=%s;DATABASE=%s;' % (dsn, user, password, database)
con = pyodbc.connect(con_string)
cur = con.cursor()
cur.execute("SELECT e.firstname, e.lastname,e.posref FROM LOCATION_ACTIVITY_DB.dbo.EMPLOYEE e")
while (1):
row = cur.fetchone ()
if row == None:
break
print "%s %s " %(row[1],row[2])
kullanici_liste()