I use the following line in a controller to add a blank record. 

record_id = db.mytable.insert() 

This works fine using MySQL but crashes with sqlite. The error is: 

File "/root/staging/1.94.5/web2py/gluon/dal.py", line 4344, in insert 
  return self._db._adapter.insert(self,self._listify(fields)) 
File "/root/staging/1.94.5/web2py/gluon/dal.py", line 763, in insert 
  raise e 
OperationalError: near ")": syntax error 

The SQL is:   INSERT INTO mytable() VALUES (); 

I get a similar error in the sqlite console but it works fine in MySQL 

sqlite> INSERT INTO mytable() VALUES (); 
Error: near ")": syntax error 

Not sure if this is a bug or not. Some dal methods produce an syntax error 
if no fields are provided. 

    db(db.mytable.id == 1).update()
    SyntaxError: No fields to update 

Should insert() without fields be a syntax error? 

Regards, 
Jim Karsten 

Reply via email to