Re: [cx-oracle-users] Inserting 'None' values
Brought to you by:
atuining
From: Jani T. <re...@gm...> - 2010-05-19 11:46:36
|
For Django ORM there was special hack to to overcome problems with that. I recall that it puts "NULL" as a string to that part of insert/update query if value for geom field was None. But truth is that as long as cx_Oracle doesn't support well underlying oracle objects it's pretty hard to get things working simple. > 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%40 > > gmail.com > > > > for further information. > > > > -- > > > > Jani Tiainen > > --------------------------------------------------------------------------- > --- > > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |