On Fri, 2007-09-07 at 11:19 +0200, pradeep kumar wrote: > Hi , > > i am trying to insert records from one table to another table in > postgres sql using the the following code > > posConn.query("insert into > usr(usr_id,usr_name,usr_passwd,grp_cde,usr_type,usr_chk_till_val, \ > > usr_active,usr_daily_auth,usr_lst_login,usr_lst_logout,usr_shift_id,usr_role_level) > values \ > ('%s','%s','%s',%s,%i,%d,'%s',%i,%i,%i,%i,%i)" > %(row[0],row[1],row[2],row[3],row[4],row[5], \ > row[7],row[8],row[10],row[11],row[12],row[14]) ) > > here row[4] column is having null value so python consides it as None > but will insert into the table it inserts as None not null value > > please help how to convert None to null value
If you were using a DB-API compliant module, you should use parameter binding instead of building query strings by hand: http://informixdb.blogspot.com/2007/07/filling-in-blanks.html However, nothing in DB-API has a .query method, so either you're using a module that's not conforming to DB-API, or you're using some kind of wrapper around a DB-API module. In any case, you should try to find out how to do parameter binding with whatever it is you're using. If it doesn't have a parameter binding mechanism, you should throw it away and replace it with a DB-API complaint module. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list