[Tutor] pymssql or ODBC

Tim Golden tim.golden at viacom-outdoor.co.uk
Fri Sep 15 10:59:54 CEST 2006


| Does anyone know how to make pymssql use windows authentication? 
|  
| Also, can anyone point me to a simple ODBC guide for SQL? 

OK, bit of a summary. If it's not answering your questions,
hopefully it'll answer someone else's!

1) mxODBC [http://www.egenix.com/files/python/mxODBC.html]
NB: Needs commercial license for non-personal use

<code>
from mx.ODBC import Windows as odbc
db = odbc.DriverConnect ("Driver={SQL
Server};Server=VODEV1;Database=EVOBACK;Trusted_Connection=yes;")

q = db.cursor ()
q.execute ("SELECT SYSTEM_USER")
for row in q.fetchall ():
  print row

</code>


2) adodbapi [http://adodbapi.sourceforge.net/]
NB Appears to be unmaintained

<code>
import adodbapi
db = adodbapi.connect ("Provider=SQLOLEDB;Data Source=VODEV1;Initial
Catalog=EVOBACK;Integrated Security=SSPI;")

q = db.cursor ()
q.execute ("SELECT SYSTEM_USER")
for row in q.fetchall ():
  print row

</code>

3) pymssql [http://pymssql.sourceforge.net/]
NB Currentish (last release Feb 2006)
doesn't support Windows auth
doesn't handle Unicode v. well (cf some recent posts on c.l.py)
the MS DLL it uses is deprecated

<code>
import pymssql
db = pymssql.connect
(host="VODEV1",user='USER',password='PASSWORD',database='EVOBACK')

q = db.cursor ()
q.execute ("SELECT SYSTEM_USER")
for row in q.fetchall ():
  print row

</code>

4) ObjectCraft mssql [http://www.object-craft.com.au/projects/mssql/]
NB Doesn't appear to be going any further
no supplied DLL for > Python 2.3
same DLL issue as pymssql
I've used it lots over the last few years and it's pretty solid

<code>
import MSSQL
db = MSSQL.connect ("VODEV1", "", "", "EVOBACK")

q = db.cursor ()
q.execute ("SELECT SYSTEM_USER")
for row in q.fetchall ():
  print row

</code>

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Tutor mailing list