Script for pickling database queries