From: <sk...@po...> - 2005-09-23 08:41:43
|
What am I doing wrong here? >>> import Sybase >>> conn = Sybase.Connection(...) >>> conn.set_property(Sybase.CS_APPNAME, "foo") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/opt/lang/python/lib/python2.3/site-packages/3rdParty/Sybase.py", line 883, in set_property status = conn.ct_con_props(CS_SET, prop, value) File "/opt/lang/python/lib/python2.3/site-packages/3rdParty/Sybase.py", line 148, in _clientmsg_cb raise DatabaseError(_fmt_client(msg)) Sybase.DatabaseError: Layer: 1, Origin: 1 ct_con_props(SET,APPNAME): user api layer: external error: This property cannot be set after a connection to a server has been established. I got the same error when trying to set the CS_HOSTNAME property. This is with 0.36 running on Solaris/Intel connecting to a 12.5 server. Thx, -- Skip Montanaro Katrina Benefit Concerts: http://www.musi-cal.com/katrina sk...@po... |
From: <sk...@po...> - 2005-09-23 09:52:50
|
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() -- Skip Montanaro Katrina Benefit Concerts: http://www.musi-cal.com/katrina sk...@po... |
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 |
From: <sk...@po...> - 2005-09-24 07:25:05
|
Dave> From this page: Dave> http://www.object-craft.com.au/projects/sybase/sybase/module-Sybase.html Dave> db = Sybase.connect('SYBASE', 'sa', '', delay_connect = 1) Dave> db.set_property(Sybase.CS_HOSTNAME, 'secret') Dave> db.connect() Dave> The delay_connect argument tells the Connection object not to Dave> connect to the server immediately. This allows you to set Dave> properties then connect using the connect() method. Thanks. I've gotten so used to working with software that has minimal documentation (much of the stuff here at work :-) or documentation that is so voluminous that it's hard to navigate around in (the major database vendors' docs qualify here), that I frequently ignore the documentation altogether or give up after a quick scan. Skip |