Here is a table definition taken from the CHINOOK sample database.
Code: Select all
CREATE TABLE InvoiceLine
(
InvoiceLineId NUMBER NOT NULL,
InvoiceId NUMBER NOT NULL,
TrackId NUMBER NOT NULL,
UnitPrice NUMBER(10,2) NOT NULL,
Quantity NUMBER NOT NULL,
CONSTRAINT PK_InvoiceLine PRIMARY KEY (InvoiceLineId)
);
I'm running this database on AWS RDS Oracle.
Here is an equivalent script to yours, which shows that a column defined as NUMBER, not NUMBER(X,0), is being returned as FLOAT. An interesting point is that both precision and scale are being returned as 38 in this case.
Code: Select all
>>> import pyodbc
>>> connection_string = """
... Driver={Devart ODBC Driver for Oracle};
... Server=XXX;
... SID=XXX;
... Username=XXX;
... Password=XXX;
... UseUnicode=1;
... Direct=1"""
...
>>> con = pyodbc.connect (connection_string)
>>> cur = con.cursor()
>>> cur.execute ('select * from chinook.invoiceline')
<pyodbc.Cursor object at 0x0074F2C0>
>>> cur.description
(('INVOICELINEID', <class 'float'>, None, 38, 38, 38, False), ('INVOICEID', <class 'float'>, None, 38, 38, 38, False), ('TRACKID', <class 'float'>, None, 38, 38, 38, False), ('UNITPRICE', <class 'float'>, None, 10, 10, 2, False), ('QUANTITY', <class 'float'>, None, 38, 38, 38, False))
>>>