inside Habbie's mind

SQL debugging tip

written by peter, on Aug 11, 2006 3:46:00 PM.

When you’re using a lot of SQL from a programming language (be it PHP or C++), put comments inside all your queries indicating which function executed them. That way, logging becomes much more useful, like this:

sqlite3_trace: SELECT /* createobject uniquecontext */
   content FROM objects WHERE id=4

(I did not come up with this trick - but it is useful enough to post here anyway.)

Leave a Reply