I'm not able to find anything SQLite specific, but this is what the
MySQL docs say about empty rows:

If both the column list and the VALUES list are empty, INSERT creates
a row with each column set to its default value:
INSERT INTO tbl_name () VALUES();
In strict mode, an error occurs if any column doesn't have a default
value. Otherwise, MySQL uses the implicit default value for any column
that does not have an explicitly defined default.

Matt


On May 11, 6:50 pm, Jim Karsten <iiijjj...@gmail.com> wrote:
> 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