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

In some limited testing it was ~10% faster. Every little bit helps right?

Change-Id: Ide55b7600d625ad151daca73fbdd8684f0f9e7f8