Take care of db closed connections

If `get_cursor` was a context manager, then calls like this would expand some but also allow transaction blocks easily