package-query
processor allows you to execute SQL queries against SQLite files present in your fastn
package.
-- record person: integer id: string name: string department:
CREATE TABLE user ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, department TEXT );
Notice how the able and the record have matching fields.
Say you have inserted some data:INSERT INTO user (name, department) VALUES ("amit", "engineering"); INSERT INTO user (name, department) VALUES ("jack", "ops");
db.sqlite
, you can fetch data from the SQLite database using package-query
processor:-- import: fastn/processors as pr -- person list people: $processor$: pr.package-query db: db.sqlite SELECT * FROM user;
The record we use must match with the result of the query, so if we would have individually selected columns, or used expressions in the SELECT clause, the type of expression must match with the record in which you are going to store the result.
You can then show the results in the FTD document, eg:-- show-person: $p $loop$: $people as $p
db
sqlite
database file is provided by the key db
.Have a question or need help?
Visit our GitHub Q&A discussion to get answers and subscribe to it to stay tuned.
Join our Discord channel and share your thoughts, suggestion, question etc.
Connect with our community!We welcome you to join our Discord community today.
We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.