Factor out database for sqlite