SQLite error handling

    Feb 01 2011 | 4:17 pm
    Is there a way to check errors occurring in the SQLite exec method? According to the docs it has no return value.
    Something stupid like forgetting to wrap a string value inside quotes when inserting into a table seems to be completely silent, which makes it difficult to debug. Is there something like a global last_error variable maybe?

    • Feb 02 2011 | 8:40 pm
      I've been wondering about this, too. I have an ongoing project which makes heavy use of SQLite from Javascript, and not being able to get any errors makes working on it so much more difficult.
      My strategy now is to try out all queries in the command-line SQLite client first to see if they are correct. In addition, I made all queries traceable (controlled by a Global), so I can manually check them for correctness in the Max window. So all my SQL code looks like this:
      var sql = ''; db.exec(sql, result); if (my_global.debug_sql) { post(sql); post(); }
      BTW, talking about SQLite API shortcomings, it would be very nice to have access to the last_insert_rowid from Javascript...
    • Feb 04 2011 | 7:06 am
      I have no experience using sql lite with max, but maybe it's useful to check what's printed in the Console.app. I remember at least seeing some sqlite errors and status update there
    • Dec 12 2014 | 8:21 pm