Extract database operations to separate module