Allows to perform queries on data stored in a SQLite database.
Syntax
sqlite('db_path', 'table_name')Arguments
db_path— Path to a file with an SQLite database. String.table_name— Name of a table in the SQLite database, or a query passed to SQLite as is (see Passing a query instead of a table name). String.
Returned value
- A table object with the same columns as in the original
SQLitetable.
Passing a query instead of a table name
Instead of a table name, the second argument can be a SELECT query that is passed to SQLite as is. The structure of the resulting table is inferred from the query result. The query can be written either as a subquery, or wrapped into the query function:
SELECT * FROM sqlite('sqlite.db', (SELECT col1, col2 FROM table1 WHERE col2 > 1));
SELECT * FROM sqlite('sqlite.db', query('SELECT col1, col2 FROM table1 WHERE col2 > 1'));Such a table is read-only: INSERT into it is not allowed. The same syntax is supported by the SQLite table engine.
Example
SELECT * FROM sqlite('sqlite.db', 'table1') ORDER BY col2;┌─col1──┬─col2─┐
│ line1 │ 1 │
│ line2 │ 2 │
│ line3 │ 3 │
└───────┴──────┘Related
- SQLite table engine
- SQLite database engine — Data types support section