that's is 4 years ago question, i think what you need, is just take the sql query, parse with nom, convert to a parse tree, then planner and execution engine, which in sqlite is vdbe will take the rest