Pythontr

husonet | Tarih: 18.10.2012

python mssql client python-pymssql

Python programlama dili ile mssql veritabanına bağlantı işlemi.

# Gerekli paketler pymssql
aptitude install python-pymssql

import pymssql

conn = pymssql.connect(host='192.168.1.111',
user='sa',
password='*****',
database='DB_VERI')
cur = conn.cursor()
cur.execute('SELECT * FROM USERS')
for row in cur:
print row

conn.close()


# python-pyodbc

import pyodbc
conn_str = 'DRIVER={FreeTDS};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s;port=1433' % ('192.168.1.111', 'DB_VERI', 'xx', 'xxxxx')
print conn_str
conn = pyodbc.connect(conn_str)
cur = conn.cursor()
cur.execute('SELECT * FROM USERS')
for row in cur:
print row
conn.close()

İlgili Konular


Linux MsSQL client kurulumu