methew / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Integer Limit Reached #283

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here's my piece of code:
cnxn = pyodbc.connect('DSN=VerticaDSN') #This is my Vertica database

cursor_count = cnxn.cursor()
count = cursor_count.execute("SELECT count(*) FROM bootups;").fetchone()[0]
print count

What is the expected output? What do you see instead?
This outputs -1065376128. The correct value should be 3230392212.
I investigated python max int size and also the other issues on this board but 
couldn't find a clear resolution to the problem.

What version of the product are you using? On what operating system?
Latest. On CentOS. Python 2.6

Please provide any additional information below.

Original issue reported on code.google.com by flavien....@gmail.com on 14 Aug 2012 at 7:58

GoogleCodeExporter commented 9 years ago
It got solved by "faking" my data to be a varchar instead of an integer. SImply 
using a cast function into my select command. Still unclear on what is really 
the issue tho.

Original comment by flavien....@gmail.com on 15 Aug 2012 at 8:02

GoogleCodeExporter commented 9 years ago
Didn't reproduce it on 64-bit OS/X 2.7.  Will try on a 32-bit Windows box 
tomorrow, which also has 2.6.

Is the CentOS box 32 or 64 bit?  Also, can you provide sys.maxint?

Original comment by mkleehammer on 17 Aug 2012 at 2:33

GoogleCodeExporter commented 9 years ago
Here are some more information about the server:
Platform | Linux
Release | CentOS release 5.5 (Final)
Kernel | 2.6.35.11-83.9.amzn1.x86_64
Architecture | CPU = 64-bit, OS = 64-bit

sys.maxint => 9223372036854775807

Original comment by flavien....@gmail.com on 17 Aug 2012 at 3:44

GoogleCodeExporter commented 9 years ago
This seems like is a driver issue.  I've added the following to pgtests 
(PostgreSQL) on tested with OS/X pyodbc 3.0.6

    def test_int_limits(self):
        values = [ (-sys.maxint - 1), -1, 0, 1, 3230392212, sys.maxint ]

        self.cursor.execute("create table t1(a bigint)")

        for value in values:
            self.cursor.execute("delete from t1")
            self.cursor.execute("insert into t1 values(?)", value)
            v = self.cursor.execute("select a from t1").fetchone()[0]
            self.assertEqual(v, value)

Can you generate an ODBC trace?

Original comment by mkleehammer on 27 Sep 2012 at 11:10

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 29 Sep 2012 at 3:09