| Issue 311: | Numpy types for inserting rows | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? 1. Use a numpy integer (numpy.int8,int16,...) 2. Insert as appropriate type in a db2 table What is the expected output? What do you see instead? It is impossible to insert using numpy types, or if inserted, the interpretation is wrong: the bits in the numpy types are interpreted wrong. What version of the product are you using? On what operating system? pyodbc 2.x and 3.x, on Linux 64-bit. Connecting to a RedHat 6.3 db2 9.7 server. Please add support for numpy types in your library! It will greatly improve how it can be used for administering numerics inserted into dbs.
Aug 27, 2013
#3
randomiz...@gmail.com
Aug 27, 2013
To be honest, the python integers are the ones that are weird. This can easily be verified with sys.getsizeof. A numpy.int64 is a c integer using 64 bits of memory. python longs uses an arbitrary number of bits, depending on the magnitude of the integer. This issue may even cause problems in the database if you try to insert an integer which is bigger than the database type allows. Example: a=long(1000) b=numpy.int64(a) sys.getsizeof(a) sys.getsizeof(b) c=2**200 d=numpy.int64(c) sys.getsizeof(c) |