making sqlite database open and close