Skip to Content
Technical Articles
Author's profile photo Ben Slade

SAP ASE Python libraries aren’t that smart

A basic piece of code using the ASE Python SDK libraries doesn’t work

conn = sybpydb.connect(user='user', password='password')
cur = conn.cursor()
cur.execute("if 1=1 select 1")
# This fetchmany call will return the error:
# sybpydb.ProgrammingError: ('No result set to fetch rows from: DBCAPI layer: unable to get origin message string: error string not available', 134349063)
rows=cur.fetchmany()
for row in rows:
  print(f"row={row}")

returns the error:

sybpydb.ProgrammingError: 
('No result set to fetch rows from: DBCAPI layer: 
 unable to get origin message string: error string not available', 134349063)

The KBA 2770299 says to call cur.rowcount to check if rows are available for the current results set before calling cursor.fetchone or cursor.fetchmany (not in the docs) then call cur.nextset to get the next results set , but that only works if there’s a buffered option for the cursor which SAP ASE Python doesn’t have.

So this will work, if you know to insert the extra cur.nextset()

conn = sybpydb.connect(user='user', password='password')
cur = conn.cursor()
cur.execute("if 1=1 select 1")
cur.nextset()
rows=cur.fetchmany()
for row in rows:
  print(f"row={row}")

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.