Are you sure it is not something else in your code that is causing this. The code you provide above looks like it should work fine. But your error message mentions the error occurs on line 35 of your test file. This tells me you have a bunch of other stuff in your test file. Strip your code down to bare minimum and test it again.
Also, test your code out using SQLite instead of Sybase. This may give you a hint as to what is going wrong as well. If the same error happens again, then we know it isn't the Sybase module causing the problem, and most likely it is with your code.