🌞
.
उपलब्ध नहीं है
इस दस्तावेज़ का अभी तक ⁨Hindi⁩ में अनुवाद नहीं हुआ है। आप ⁨English⁩ संस्करण देख रहे हैं।
$processor$: package-query

package-query processor allows you to execute SQL queries against SQLite files present in your fpm package.

Say you have a record and a variable like this:

-- record person:
integer id:
string name:
string department:

-- person list people:
And say you have an SQLite database file with table like this:
sqlite3 db.sqlite
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");
Assuming the SQLite file is db.sqlite, you can fetch data from the SQLite database using package-query processor:
-- people:
$processor$: 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: $p
$loop$: $people as $p

-- ftd.text show-person: $p.name
person p:
db
The name of sqlite database file is provided by the key db.