Re: [cx-oracle-users] Inserting 'None' values
Brought to you by:
atuining
From: Tobias S. <tob...@ca...> - 2010-05-19 06:40:11
|
Thanks for your reply, Jani. This is too bad, because I am using cx_Oracle through SQLAlchemy and SQLAlchemy uses all columns in an insert statement. The problem is that cx_Oracle does not know the type for the column for which I want to insert a NULL value? Would it work if I pass something like 'cx_Oracle.OBJECT.NoneObject' or 'cx_Oracle.OBJECT.NoneObject('MDSYS.SDO_GEOMETRY')' to cx_Oracle? > > Hi, > > > > I am trying to use a Python 'None' value as bind parameter for a > > > > geometry column in an insert statement, but this does not work: > > >>> cursor.executemany('insert into spots values(:id, :height, :geom)', > > >>> [{'id': 14, 'height': 2, 'geom': None}]) > > > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > cx_Oracle.DatabaseError: ORA-00932: inconsistent datatypes: expected > > MDSYS.SDO_GEOMETRY got CHAR > > > > >>> cursor.executemany('insert into spots values(:id, :height, NULL)', > > >>> [{'id': 14, 'height': 2}]) > > > > I don't know what query is actually sent to the database, but it seems > > as if 'None' is not converted to 'NULL'. And using 'None' as bind > > parameter for the decimal column 'height' works. > > > > Is this a bug? > > Expected behaviour, see > http://sourceforge.net/mailarchive/message.php?msg_name=49F050EC.30205%40gmail.com > > for further information. > > -- > > Jani Tiainen |