Use prepared statements for readonly extraction

These statements don't involve the temp tables so are
identical in the writable and readonly apidb backends.
Merge pull request #72 from pnorman/readonly_prepared

Use prepared statements for readonly extraction