1.3 Testing

The most simple way to test the Sybase package is to run a test application. The arguments to the Sybase.connect() function are server (from the interfaces file), username, password, and database. The database argument is optional. Make sure you substitute values that will work in your environment.

>>> import Sybase
>>> db = Sybase.connect('SYBASE', 'sa', '')
>>> c = db.cursor()
>>> c.callproc('sp_help')
>>> for t in c.description:
...     print t
... 
('Name', 0, 0, 30, 0, 0, 0)
('Owner', 0, 0, 30, 0, 0, 32)
('Object_type', 0, 0, 22, 0, 0, 32)
>>> for r in c.fetchall():
...     print r
... 
('spt_datatype_info', 'dbo', 'user table')
('spt_datatype_info_ext', 'dbo', 'user table')
('spt_limit_types', 'dbo', 'user table')
  :
  :
('sp_prtsybsysmsgs', 'dbo', 'stored procedure')
('sp_validlang', 'dbo', 'stored procedure')
>>> c.nextset()
1
>>> for t in c.description:
...     print t
... 
('User_type', 0, 0, 15, 0, 0, 0)
('Storage_type', 0, 0, 15, 0, 0, 0)
('Length', 6, 0, 1, 0, 0, 0)
('Nulls', 11, 0, 1, 0, 0, 0)
('Default_name', 0, 0, 15, 0, 0, 32)
('Rule_name', 0, 0, 15, 0, 0, 32)