Skip to content

How to retrieve bigint with IfxPyDbi #73

Description

@zdenop

I have a problem retrieving BIGINT value with IfxPyDbi. Instead of value, I am receiving None.
Here is my code:

import IfxPyDbi 

con_str="..."
connection = IfxPyDbi.connect(con_str)
cursor = connection.cursor()
query = f"SELECT * FROM sdgk LIMIT 1"
cursor.execute(query)
print("\ncursor.description:\n")
print(cursor.description)
print("\ndata:\n")
print(cursor.fetchall())

Output (BIGINT column name is sin):

cursor.description:

[['sin', DBAPITypeObject({'CHARACTER VARYING', 'STRING', 'VARCHAR', 'CHAR VARYING', 'CHAR', 'CHARACTER'}), 20, 20, 20, 0, False], 
 ['servicetype', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 5, 5, 3, 0, False],
 ['inkassoattr', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 4, 4, 2, 0, True],
 ['inkasso_sys', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 11, 11, 9, 2, True], 
 ['inkasso_fcu', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 11, 11, 9, 2, True], 
 ['inkassodat', DBAPITypeObject({'DATE'}), 10, 10, 10, 0, True],
 ['inkassovars', DBAPITypeObject({'CHARACTER VARYING', 'STRING', 'VARCHAR', 'CHAR VARYING', 'CHAR', 'CHARACTER'}), 100, 100, 100, 0, True],
 ['inkassomodus', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 4, 4, 2, 0, True], ['motiv', DBAPITypeObject({'DECIMAL', 'NUMERIC', 'NUM', 'DEC'}), 4, 4, 2, 0, True],
 ['fibu_kz', DBAPITypeObject({'CHARACTER VARYING', 'STRING', 'VARCHAR', 'CHAR VARYING', 'CHAR', 'CHARACTER'}), 1, 1, 1, 0, True]]

data:

[(None, Decimal('3'), Decimal('0'), Decimal('0.00'), Decimal('0.00'), None, None, None, None, None)]

As you can see BIGINT column is recognized as VARCHAR

I also tried to use IfxPy, but with the same result:

import IfxPy

conn = IfxPy.connect(config.ConnStr, config.user, config.password)
if conn:
    server = IfxPy.server_info(conn)
    print("server:", server.DBMS_NAME)
    if server.DBMS_NAME[0:3] == "Inf":
        op = {IfxPy.ATTR_CASE: IfxPy.CASE_UPPER}
        IfxPy.set_option(conn, op, 1)

    stmt = IfxPy.prepare(conn, "SELECT * FROM sdgx LIMIT 1")
    IfxPy.execute(stmt)
    data = IfxPy.fetch_both(stmt)
    while data:
        print(data)
        data = IfxPy.fetch_both(stmt)
    IfxPy.close(conn)
else:
    print("Could not make db connection.")

output:

server: Informix
{'SIN': None, 0: None, 'SERVICETYPE': '3', 1: '3', 'SERVICEATTR': '0', 2: '0', 'SERVICEWERT': '20.940', 3: '20.940', 'SERVICESTATUS': '1', 4: '1', 'SERVICEVARS': None, 5: None, 'SURCHARGES': None, 6: None}

But when I connected to db with DBeaver (jodbc), column was correctly identified as biting and values were shown correctly.

image

What I am doing wrong?
I am using IfxPy 3.0.5, Python 3.9.9 64bit, database IBM Informix Dynamic Server Version 12.10.FC7WE.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions