Convert readonly backend to use prepared statements and arrays

Fixes #58 mostly, but there remains an issue with the outputter and chunking being more difficult to convert, so leaving that until #71 is figured out.