we are using python 2.7.1 and sqlanydb 1.0.5 (now officially supported by SAP). When fetching data from our IQ 15 server, any data that is not an integer like (smallint, int ...) is returned as "unicode", loosing the data type mapping to Python data types.
When using the ASE python-sybase library (aka Sybase) 0.39, fetching data preserves data types.
We have contacted the customer support, but unfortunately they could not provide us any solution for the case.
Did anybody experienced a similar problem?
Unfortunately decoding and casting the data to the appropriated data types is a very slow options when you fetch a couple million rows.
Thanks in advance for the help.
Cris da Rocha
asked 17 Sep '14, 08:40
Cris da Rocha
Whether the casting is done in your application or in the sqlanydb driver, it will take the same amount of time. The sqlanydb driver is written on top of our dbcapi library, which returns everything as a string, so the casting is necessary.
We are investigating ways that we could return native python types without the need for casting, but unfortunately I do not have a solution for you right now.
answered 17 Sep '14, 10:34
Re: any data that is not an integer like (smallint, int ...) is returned as "unicode".
The binary datatypes (BINARY, LONG BINARY, VARBINARY, IMAGE) are returned as "str" (the str class).
You haven't said what "native" datatypes you want to use. Have you considered using converters? These work well with specialized data types like datetime or decimal. The only built-in type we don't intrinsically support is boolean but a converter can be used here as well.
If you are looking for high-performance data transfers, Python may not be a good choice. For example, a Python application fetching 100,000 rows each containing 100 integer columns is approximately 37x slower than an ODBC applicaton doing the same thing.