Cant find the correct syntax for INSERT query with python informixdb
- python 2.6.6
- python INFORMIXDB version 2.5
- driver name : IBM Informix-ESQL
- driver version : 3.50.FC8
- on debian squeeze
here’s the doc – http://informixdb.sourceforge.net/manual.html#binding-parameters
>>> cursor.execute('INSERT INTO names VALUES(:first,:last,:age)',
... dict(first='some', last='body', age=56) )
So i tried for example
cursor.execute('INSERT INTO transit_auftrag_i VALUES(:auftragskey,:transitkunde,:status)',dict(auftragskey='erII',transitkunde='DMIeLE',status='OK') )
this is what i get in this example
<class '_informixdb.ProgrammingError'>
('PREPARE', -236, [{'message': 'Insert value list does not match column list', 'sqlstate': '21S01'}])
<class '_informixdb.ProgrammingError'>
('DESCRIBE', -410, [{'message': 'Syntax error or access violation in PREPARE or EXECUTE IMMEDIATE', 'sqlstate': '37000'}])
Segmentation fault
any hints what i could try please?
UPDATE: informix 11.50.xC8
UPDATE
thanks so far. I do the following query now which runs without errors, but also with no message from the cursor and it does not insert anything. If you have a suggestion it would be great.
cursor.execute("INSERT INTO transit_auftrag_i (auftragskey,transitkunde,status) VALUES (:a,:b,:c)", dict(a='A',b='B',c='C') )
You should list the columns explicitely that you want to populate:
INSERT INTO names (firstname, lastname, age) VALUES (:first,:last,:age)Apperently your table has more columns than you supply, or they are in a different order.
Not stating the columns for an
INSERTstatement is a bad programming habit, that you should get rid off as quick as possible