> > With 140 fields, you get queries nested 140 levels deep in parentheses, > which SQLite cannot handle. Of course, all of the nested parentheses are > not really necessary, so if you want to first check for the existence of a > record, one option is to avoid using .update_and_insert() and instead write > your own code to check for record existence. You code would have to > manually construct the "WHERE" clause of the SQL query. The logic then > might look something like: > > record = db(manually_generated_raw_SQL).select(db.WCEL.id, limitby=(0, 1 > )).first() > if not record: > db.WCEL.insert(**WCEL) >
Note, one simple way to generate the raw SQL query is something like: str(reduce(lambda a, b: a & b, [db.WCEL[f] == v for f, v in iteritems(WCEL )])).replace('(', '').replace(')', '') That generates the same query .update_or_insert would generate, converts it to SQL via str() and then simply removes all the parentheses. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.