anthony-tuininga / ceODBC

Python module for accessing databases using the ODBC API.
https://anthony-tuininga.github.io/ceODBC/
12 stars 8 forks source link

insert a big long integer #5

Closed ericksc closed 3 years ago

ericksc commented 5 years ago

I have a piece of code with a current SQL query to insert. I was trying to insert a big long integer but It fails it.

I noticed currently there is a possibility on that way to use ceODBC.BigIntegerVar.

my question is: is possible to support big int by default? I want to avoid to detect and /or convert any big int to ceODBC.BigIntegerVar.


        big_number = (2 ** i) - 1
        #insert a row
        print('Trying to insert bin number 2**{} -> {} '.format(i , big_number))
        cursor.executemany(sql_insert, [(i, my_date, test_name , big_number)])
        cursor.commit()
ericksc commented 5 years ago

it is at Python3,

another question. at python2, why does big integer is fully supported without setup any ceODBC.BigIntegerVar?

Could you please check that behavior? thank you in advance

senco commented 5 years ago

Anthony: to reproduce add this test to sqlserver\NumberVar.py works in py2 but fails in py3: def testBindLongInteger(self): "test binding in a long integer" self.cursor.execute(""" update TestNumbers set BigIntCol = ? where IntCol = ?""", self.dataByKey[3][1], 3) self.cursor.execute(""" select * from TestNumbers where IntCol = ?""", 3) self.failUnlessEqual(self.cursor.fetchall(), [self.dataByKey[3]])

anthony-tuininga commented 3 years ago

ceODBC 3.0 was just released. It contains test cases that test binding big integers (1303) and fetching big integers (1310) among others. Let me know if this is still an issue. For the situation with executemany(), you need to use setinputsizes() if the initial values are plain integers and subsequent values are big integers.