I was wondering, how can i parse a SQLIte Query, and tokenize it in order to get the future to be affected entries after the execution of the query, to be able to set policies on a single SQLite database?
So far i have created a project that accepts modules. And there is a single SQLite database. My goal is to create a Controller which will receive the queries from each Module, and essentially check if this module is allowed to change a particular thing in the database.
Any ideas on how to accomplish this? Is there any library for this or something? I have searched a lot but didn't find any solution in 6 months.
The easiest way to parse SQLite queries is to let SQLite itself run them.
If you proceed the SQL statement with EXPLAIN
, you'll get a result set containing the virtual machine instructions (without actually executing the query). If you look at the rows that have opcode = 'TableLock'
, the p4
column will give you the name of the table affected.