I should have added that you can check for inserted/deleted/updated tables by looking for more codes than SQLITE_CREATE_TABLE. The provided sample code only checks for table creation.
Gwendal > Le 29 oct. 2017 à 15:28, Gwendal Roué <gwendal.r...@gmail.com> a écrit : > > Yes, there is a general way. > > To know if a statement creates a database table, > > 1. Open a private, in-memory, database connection > 2. Register an authorizer with sqlite3_set_authorizer > (https://sqlite.org/c3ref/set_authorizer.html > <https://sqlite.org/c3ref/set_authorizer.html>). > 3. Compile the statement with sqlite3_prepare_v2 > (https://sqlite.org/c3ref/prepare.html > <https://sqlite.org/c3ref/prepare.html>) > 4. In the registered authorizer callback, check for SQLITE_CREATE_TABLE > (https://www.sqlite.org/c3ref/c_alter_table.html > <https://www.sqlite.org/c3ref/c_alter_table.html>). > > Find attached a C program that demonstrates the technique. > > $ cc -lsqlite3 created_table.c && ./a.out > Create table foo: CREATE TABLE foo(a, b) > No table creation: INSERT INTO bar (a) VALUES (1) > No table creation: Some invalid SQL > > <created_table.c> > > Gwendal Roué > >> Le 28 oct. 2017 à 14:44, Shane Dev <devshan...@gmail.com >> <mailto:devshan...@gmail.com>> a écrit : >> >> Hello, >> >> Let's say I have a table containing of SQL statements, for example >> >> sqlite> .schema sql >> CREATE TABLE sql(statement text); >> >> sqlite> select * from sql; >> insert into tab1 select 'example text'; >> update tab2 set col2 = 123 where col2 = 1; >> delete from tab3 where col1 = 2; >> >> For the first row, I could build a query using instr and substr functions >> to extract the first word after INSERT INTO. That would work for most >> simple INSERT statements, but it would fail if (for example) the statement >> was prepended with a WITH clause which happened to contain the text "INSERT >> INTO". Is there more generalized way of achieving this? >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@mailinglists.sqlite.org >> <mailto:sqlite-users@mailinglists.sqlite.org> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users