Looks like you are opening the database then forking. This does not work. You must fork then open the database.