Switch to v2 sqlite interface in base_init and base_close
Some code formatting
Use large buffer instead copying for DB request result