[python-sybase] Problem with calling stored procedures

Dave Cole djc at object-craft.com.au
02 Apr 2002 22:31:01 +1000


> Hello, I think the old problem with calling some stored procedures
> still seems to be there.
> 
> Namely, I still can't get any sensible results from calling
> sp_helpindex.  The code is something like:
> 
> 
> def getindex(table):
>     print "getindex", table
>     c = cnx.cursor()
>     c.callproc("sp_helpindex", [table])
>     l = c.fetchall()
>     print l
>     while c.nextset():
>         l = c.fetchall()
>         print l
> 
> cnx=Sybase.connect("<server>","<uname>","<pass>")
> cnx.cursor().execute("use mydb")
> 
> getindex("mytable")

Hmm...  It Seems To Work For Me With 0.34 (TM)

>>> import Sybase
>>> db = Sybase.connect('SYBASE', 'sa', '')
>>> db.cursor().execute('use pubs2')
>>> c = db.cursor()
>>> c.callproc('sp_helpindex', ['titles'])
>>> for r in c.fetchall():
...     print r
... 
('titleidind          ', 'clustered, unique located on default                    ', ' title_id', 0, 0, 0)
('titleind            ', 'nonclustered located on default                         ', ' title', 0, 0, 0)
>>> c.nextset()
1
>>> for r in c.fetchall():
...     print r
... 
(0,)
>>> c.nextset()
>>> 

- Dave

-- 
http://www.object-craft.com.au