does db.executesql not fit ? Niphlod
On 31 Ott, 18:01, siddharth <[email protected]> wrote: > Hi, I need to do an upsert in a database table. I need to insert a row > if it does not exist already and and update it if it does. > using python sqlite module I was writing the code as > > code (python : curs holds the cursor to table ): > > curs.execute("insert or ignore into table values(?,?)",(name_var,0)) > curs.execute("update docs set freq=freq+1 where name ='"+name_var+ > "'") > > The table contains two columns : name (type text, primary key) and > freq (type integer). it name_var is a variable that holds the name to > query the database. > > How do I achieve the same code in web2py? I tried db.executesql() but > am having problem with it because of the quotes involved. > > Thank you.

