SQLite Forum

Database Independent Queries
Login

Database Independent Queries

(1) By anonymous on 2021-03-25 09:02:34 [link] [source]

With the CLI, I can execute a database independent query such as:

select * from pragma_database_List;

The SQL has no dependency on any database. Is there a way to execute the same query using sqlite3_exec without opening a database i.e. omitting the first argument (which is a database handle)?

(Using C#, I tried using IntPtr.Zero as the first argument but that returns SQLITE_MISUSE (21) i.e. Library used incorrectly)

(2) By Richard Hipp (drh) on 2021-03-25 13:01:55 in reply to 1 [source]

sqlite3_exec() is a method on the database connection object. You cannot run sqlite3_exec() without having a database connection to run it on.

You can, however, create a database connection object on an (empty) in-memory database and use that.