converted sqldb to a plugin so it can be reloaded

changed statdb to use it