OpenInformix / IfxPy

Informix native Python driver for scalable enterprise and IoT solutions.
Other
46 stars 22 forks source link

Boolean values ​​return None #16

Closed ivanarielcaceres closed 5 years ago

ivanarielcaceres commented 5 years ago

Hi everybody!

When I read columns of type Boolean T | F, I return None. Is there any configuration or parameter needed to read them correctly?

Thanks in advance

ivanarielcaceres commented 5 years ago

Hi!

I really need to solve this issue. I understand that boolean values requrires special mapping but what can i do in this situation?

jsagrera commented 5 years ago

Support for boolean was never fully implemented in the module. Just commited some changes which should allow you to select a bool column. Try the new ifxpyc.c file and rebuild the module.

informix@irk:/data/informix/IBM/OpenInformix/Py$ cat bool.py 
import IfxPy

ConStr="Driver={IBM INFORMIX ODBC DRIVER};SERVER=irk1210;DATABASE=stores7;host=irk;service=9088;protocol=onsoctcp"

conn=IfxPy.connect(ConStr,"informix","dummy")
if conn:
      stmt = IfxPy.exec_immediate(conn, "SELECT 'T'::boolean,'F'::boolean FROM systables")
      res = IfxPy.fetch_tuple(stmt)      
      print (res[0],res[1])
      if res[0]:
         print ("col0 is true")
      else:
         print ("col0 is false")
      if res[1]:
         print ("col1 is true")
      else:
         print ("col1 is false")

informix@irk:/data/informix/IBM/OpenInformix/Py$ python bool.py 
(1, 0)
col0 is true
col1 is false
informix@irk:/data/informix/IBM/OpenInformix/Py$ 

ivanarielcaceres commented 5 years ago

Thanks! It worked like a charm.