[python-sybase] python-sybase + FreeTDS + MS SQL Server

Charles Bearden Charles.F.Bearden at uth.tmc.edu
Mon, 2 Aug 2004 17:04:26 -0500


I have built freetds-0.62.4 on a RH9 box, and it seems to work based on
tests with tsql.  After setting the environment variables and proceeding
a la=20

  http://www.freetds.org/userguide/python.htm

I successfully installed the Python Sybase module.

My question is how to supply authentication credentials to the MS SQL
Server.  I have to use a domain login userid like DOMAIN\username.  When
I create a Python script like this:

------------------------------------------------------------
import Sybase

dsn =3D 'theDb'
uid =3D 'MYDOMAIN\jrandomuser'
pwd =3D 'h4x0r'
cx =3D Sybase.connect(dsn, uid, pwd)

cx.close()
------------------------------------------------------------

(where 'theDB' is an actually defined profile in my freetds.conf, and
'uid' contains a working domain username and 'pwd' the corresponding
password, I get an exception like so:

Sybase.DatabaseError: Msg 18452, Level 14, State 1
Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server
 connection.Layer: 0, Origin: 0
Login incorrect.

It seems not to like something about the way I specify the username.  I
checked the docs, and the python-sybase list archives back into last
year, and I didn't find anything to enlighten me.  Is this doable?

Thanks for any pointers,

Chuck Bearden
Systems Analyst III
School of Health Information Sciences
University of Texas at Houston
713.500.3954 (voice)
713.500.3907 (fax)
Charles.F.Bearden@uth.tmc.edu