Search code examples
pythonsap-asepyodbc

why pyodbc query to Sybase db returning partial data with some garbage?


I recently started using a Windows 7 box. I am trying to query a Sybase database using 32-bit ASE drivers (Adaptive Server Enterprise). The Sybase client installed on the machine is v15.5.

The issue is that when I query for small data I get correct result but if the result expected is more than 40 rows I am getting an error.

  >>> x = smd.Query("select ric_code as ric, weight, adjusted_weight as adjweight,
  currency as currency, close_price as last from v_temp_idx_comp where index_ric_
 code='.HSI'")
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "s:\quant\python\v1.0\smd.py", line 15, in Query
     result = x.fetchall()
 pyodbc.Error: ('HY000', 'The driver did not supply an error!')

I am not sure how to resolve this error. What steps can I take to debug this further? Can I use some command line tools to investigate further? how about isql? Will they use same underlying drivers?

FYI, there is no issues with the query. The query works very well on my previous machine which used Merant driver.

Any suggestions are welcome.


Solution

  • I just came across this post of yours because I was running into the exact same issue. (Windows 7 and Sybase ASE 15.5 [only python 2.7.2 in my case].)

    I think I just figured out my problem: one of the columns in the table I was querying was defined as having "bigint" data type. Since this is a new table for me, I dropped the table and recreated it using only "int" as the data type, and now it works just fine. I was lucky because it turned out that I really don't need the extra capacity of the "bigint" type -- "int" is enough for what I'm doing.