MySql + insert()

15 views
Skip to first unread message

Ole Trenner

unread,
Mar 13, 2011, 3:32:53 PM3/13/11
to we...@googlegroups.com
Hi everyone,

I've stumbled upon a thing where you can probably help me out.
It seems as if DB.insert(...) creates an invalid query if no values have been specified:

py code:
new_id = mydb.insert('mytable')

generates the query:
"INSERT INTO mytable DEFAULT VALUES"

This query doesn't work in MySQL (although it does in SQLite). I don't know if this is the expected behaviour or not, but so far I had to circumvent this thing by using something like

new_id = mydb.insert('mytable', id=SQLLiteral('DEFAULT'))

(which, unfortunately, doesn't work in SQLite)
Do you know how to fix this or how to create a more database-agnostic solution for inserts without values?

Thanks a lot for your help.
Ole.


--
Ole Trenner
<o...@jayotee.de>


Anand Chitipothu

unread,
Mar 14, 2011, 6:46:00 PM3/14/11
to we...@googlegroups.com
2011/3/13 Ole Trenner <o...@jayotee.de>:


Added issue for this.

https://github.com/webpy/webpy/issues/49

Anand

Reply all
Reply to author
Forward
0 new messages