
What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. Changes: - A Numeric object exposes the Sybase numeric / decimal data type to Python. Columns of type numeric / decimal will be returned as Numeric objects. Numeric objects can be used in almost all places as other Python number objects. The following operations have been implemented; +, -, *, /, int(), float(), long(), str(), cmp(), repr(), hash(), abs(). A Numeric object has two readonly attributes; precision, and scale. You can create a new Numeric object by using the Sybase.numeric(value) function. This will convert the int / long / float / string object passed as value to Numeric. At the moment, money and money4 types are still transformed into float objects because I have not worked out how to tell the Sybase library to generate the right number of decimal places in arithmetic results. For example: You can pickle the new numeric data type.
import Sybase n = Sybase.numeric(100200300400500L) n.precision, n.scale (77, 0) m = Sybase.numeric(n, 30, 2) m 100200300400500.00 m.precision, m.scale (30, 2)
If you want to increase the scale without modifying the precision, pass -1 as the precision.
m = Sybase.numeric(n, -1, 4) m 100200300400500.0000 m.precision, m.scale (77, 4)
Where can you get it: http://www.object-craft.com.au/projects/sybase/ - Dave -- http://www.object-craft.com.au
participants (1)
-
Dave Cole