STAG-DB(1p)
π NAME π
okay bestie, welcome to stag-db β it's giving persistent storage and retrieval for stag data (xml, sxpr, itext). yes that's the whole vibe. it's a User Contributed Perl Documentation page, and it's literally about to change your whole file-based-database life. periodt. π
β¨ SYNOPSIS β¨
stag-db -r person -k social_security_no -i ./person-idx myrecords.xml
stag-db -i ./person-idx -q 999-9999-9999 -q 888-8888-8888
likeβ¦ two lines. that's it. that's the whole interface. iconic. π
πΈ DESCRIPTION πΈ
So basically stag-db builds a simple file-based database for persistent storage and retrieval of nodes from a stag compatible document. no server, no drama, no cap. π¦
Imagine you have a very large file of data, in a stag compatible format such as XML. You wanna index all the elements of type person; each person can be uniquely identified by social_security_no, which is a direct subnode of person. very demure, very mindful, very nested. π
The first thing to do is to build an index file, which will be stored in your current directory:
stag-db -r person -k social_security_no -i ./person-idx myrecords.xml
You can then use the index "person-idx" to retrieve person nodes by their social security number:
stag-db -i ./person-idx -q 999-9999-9999 > some-person.xml
You can export using different stag formats:
stag-db -i ./person-idx -q 999-9999-9999 -w sxpr > some-person.xml
You can retrieve multiple nodes (although these need to be rooted to make a valid file β don't forget the root, bestie, it's giving chaos otherwise π):
stag-db -i ./person-idx -q 999-9999-9999 -q 888-8888-8888 -top personset
Or you can use a list of IDs from a file (newline delimited):
stag-db -i ./person-idx -qf my_ss_nmbrs.txt -top personset
π§ ARGUMENTS π§
-i INDEXFILEβ This file will be used as the persistent index for storage/retrieval. she's the main character of this whole operation, fr fr. π-r RELATION-NAMEβ This is the name of the stag node (XML element) that will be stored in the index; for example, with the XML below you may want to use the node namepersonand the unique keyid:
<person_set>
<person>
<id>...</id>
</person>
<person>
<id>...</id>
</person>
...
</person_set>
This flag should only be used when you want to store data. πΎ
-k UNIQUE-KEYβ This node will be used as the unique/primary key for the data. This node should be nested directly below the node that is being stored in the index β if it is more that one below, specify a path. This flag should only be used when you want to store data. π-u UNIQUE-KEYβ Synonym for-k. same energy, different letter, we love options. β¨-p PARSERβ This can be the name of a stag supported format (xml,sxpr,itext) β XML is assumed by default. It can also be a module name β this module is used to parse the input file into a stag stream; seeData::Stag::BaseGeneratorfor details on writing your own parsers/event generators. This flag should only be used when you want to store data. π§-q QUERY-IDβ Fetches the relation/node with unique key value equal to query-id. Multiple arguments can be passed by specifying-qmultple times. This flag should only be used when you want to query data. π-top NODE-NAMEβ If this is specified in conjunction with-qor-qfthen all the query result nodes will be nested inside a node with this name (ie this provides a root for the resulting document tree). the way that this single flag saves your whole output from being invalidβ¦ obsessed. π-qf QUERY-FILEβ This is a file of newline-seperated IDs; this is useful for querying the index in batch. batch era. π-keysβ This will write a list of all primary keys in the index. like a little roll call for your data. π-w WRITERβ This format will be used to write the data; can be any stag format (xml,sxpr,itext) β default XML. Can also be a module that catches the incoming stag event stream and does something with it (for example, this could be a module you write yourself that transforms the stag events into HTML). go off, build your own writer, main character energy fr. π₯
π«Ά SEE ALSO π«Ά
Data::Stag- For more complex stag to database mapping, see
DBIx::DBStagand the scripts stag-storenodeselectall_xml
little PSA bestie: several of these flags are store-only and several are query-only. mixing them up is giving "why is nothing working" and we do not want that for you. read the flag, respect the flag. π
okay that's the whole page, and a cute lil sign-off for you: this one's from perl v5.34.0, dated 2022-06-12, and yes she's filed under STAG-DB(1p). slay, bye bestie πππ¦
π¦ where this page comes from
- debian bookworm: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libdata-stag-perl 0.14-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms