Reuse a cursor instead of a conn.execute for better performance

Basically the same thing as https://review.openstack.org/#/c/109694/
but over in the account backend.

Change-Id: I9255f3145818da3adafc16d3bcf159608a78fe51