[sqlite] Determine query type

2015-08-07 Thread Martin Engelschalk
Hi Stephan Ben and all, by the way: checking the column count only applies to SQLite. Other databases (Postgres, Oracle) support the insert into returning or update ... returning syntax, resulting in statements that change the database and have columns at the same time. This is a feature I

[sqlite] Determine query type

2015-08-06 Thread Stephan Beal
On Thu, Aug 6, 2015 at 6:57 PM, Ben Newberg wrote: > Excellent. This is exactly what I was looking for. > Great :). Now that i have some code in front of me i can say, more concretely, that sqlite3_column_count() is what you want. https://www.sqlite.org/c3ref/column_count.html -- - stepha

[sqlite] Determine query type

2015-08-06 Thread Stephan Beal
On Thu, Aug 6, 2015 at 6:46 PM, Ben Newberg wrote: > Is there a good way to determine if a sql query is either attempting to > modify a database, or simply querying it? > Check the column count of the prepared statement: it will be >0 for a select or select-like pragma. Anything else is an updat

[sqlite] Determine query type

2015-08-06 Thread Nelson, Erik - 2
> users-bounces at mailinglists.sqlite.org] On Behalf Of Scott Hess wrote on > Thursday, August 06, 2015 1:11 PM > > Also consider https://www.sqlite.org/c3ref/stmt_readonly.html > > On Thu, Aug 6, 2015 at 10:08 AM, Stephan Beal > wrote: > > > On Thu, Aug 6, 2015 at 6:57 PM, Ben Newberg > wro

[sqlite] Determine query type

2015-08-06 Thread Ben Newberg
Excellent. This is exactly what I was looking for. Thanks. On Thu, Aug 6, 2015 at 11:50 AM, Stephan Beal wrote: > On Thu, Aug 6, 2015 at 6:46 PM, Ben Newberg wrote: > > > Is there a good way to determine if a sql query is either attempting to > > modify a database, or simply querying it? > > >

[sqlite] Determine query type

2015-08-06 Thread Ben Newberg
Is there a good way to determine if a sql query is either attempting to modify a database, or simply querying it? In the past, I have used sqlite3_update_hook with good results, but in this current project, I am looking for a way to determine the type of query even before the prepared statement is

[sqlite] Determine query type

2015-08-06 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/06/2015 09:46 AM, Ben Newberg wrote: > Is there a good way to determine if a sql query is either > attempting to modify a database, or simply querying it? You most like want to use the authoriser. It tells you exactly what the query is doing, a

[sqlite] Determine query type

2015-08-06 Thread Scott Hess
Also consider https://www.sqlite.org/c3ref/stmt_readonly.html -scott On Thu, Aug 6, 2015 at 10:08 AM, Stephan Beal wrote: > On Thu, Aug 6, 2015 at 6:57 PM, Ben Newberg wrote: > > > Excellent. This is exactly what I was looking for. > > > > Great :). Now that i have some code in front of me i c