Monday, 18 July 2011

sqlite log filtering

Hi,

Presumably a lot of you are developing rails applications using sqlite.
In this case the log is spamed by some pesky sql statements every time our app accesses the db.



SQL (0.6ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.6ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
...
SQL (0.6ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.6ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
...



These messages bother me because they have nothing to do with my application logic, they are only needed by the sqlite driver to access the db structure.


Therefore I developed a small ruby gem called sqlite_log_filter which filters these messages out. The source can be found on github


All you need to do is to put it in your gemfile

gem 'sqlite_log_filter'


Then bundle it

bundle install


Hopefully it helps :)