From: Dave C. <dj...@ob...> - 2005-09-23 23:04:16
|
sk...@po... wrote: > skip> What am I doing wrong here? > > ... > >>>> conn.set_property(Sybase.CS_APPNAME, "foo") > ... > skip> ct_con_props(SET,APPNAME): user api layer: external error: This property > skip> cannot be set after a connection to a server has been established. > > Looking at the Open Client docs on the Sybase site it says that CS_APPNAME > and CS_HOSTNAME are login properties that take effect "only if set before > the connection is established". I eventually figured out that a change was > needed to Sybase.Connection.__init__. here's a udiff against 0.37: > > --- Sybase.py.~1~ 2005-04-06 17:46:43.000000000 -0500 > +++ Sybase.py 2005-09-22 11:49:58.849060000 -0500 > @@ -836,7 +836,8 @@ > class Connection: > > def __init__(self, dsn, user, passwd, database = None, > - strip = 0, auto_commit = 0, delay_connect = 0, locking = 1): > + strip = 0, auto_commit = 0, delay_connect = 0, locking = 1, > + appname = "", hostname = ""): > '''DB-API Sybase.Connect() > ''' > self._conn = self._cmd = None > @@ -863,6 +864,14 @@ > status = conn.ct_con_props(CS_SET, CS_PASSWORD, passwd) > if status != CS_SUCCEED: > self._raise_error(Error, 'ct_con_props') > + if appname: > + status = conn.ct_con_props(CS_SET, CS_APPNAME, appname) > + if status != CS_SUCCEED: > + self._raise_error(Error, 'ct_con_props') > + if hostname: > + status = conn.ct_con_props(CS_SET, CS_HOSTNAME, hostname) > + if status != CS_SUCCEED: > + self._raise_error(Error, 'ct_con_props') > if not delay_connect: > self.connect() >From this page: http://www.object-craft.com.au/projects/sybase/sybase/module-Sybase.html db = Sybase.connect('SYBASE', 'sa', '', delay_connect = 1) db.set_property(Sybase.CS_HOSTNAME, 'secret') db.connect() The delay_connect argument tells the Connection object not to connect to the server immediately. This allows you to set properties then connect using the connect() method. - Dave -- http://www.object-craft.com.au |