Fixing the run_query to renew the connection if it times out.

There are two reasons that run_query will stop working after the initial run, requiring a restart: timeout and too many connections.

Adding Memoise solves the issue with of having too many connections.  The connection can still time out if enough time passes between runs.