SELECTALL_XML(1p)
π SELECTALL_XML π
okay bestie, gather round π«Ά this is SELECTALL_XML(1p), a lil gem from the User Contributed Perl Documentation collection, and it's about to become your new fave. no cap.
β¨ NAME β¨
stag-selectall_xml β query every single element from a database and get XML back out. it's giving database-to-XML pipeline realness. π
πΈ SYNOPSIS πΈ
stag-selectall_xml [-d <dbi>] [-f file of sql] [-nesting|n <nesting>] SQL
π¦ DESCRIPTION π¦
so here's the tea β β this script queries a database using either SQL that you (the user) handed it, or an SQL template. then it takes those query results and turns them into XML via the DBIx::DBStag module. obsessed. π₯
the nesting of that XML? you control it with the DBStag SQL extension USE NESTING.... iconic behavior honestly.
π EXAMPLES π
stag-selectall_xml -d "dbi:Pg:dbname=mydb;host=localhost"\
"SELECT * FROM a NATURAL JOIN b"
look at that backslash line continuation go β¨
π TEMPLATES π
instead of typing out the whole entire SQL, you can use a parameterized SQL template (aka a canned query). so much chiller.
for example:
stag-selectall_xml -d genedb /genedb-gene gene_symbol=Adh
or:
stag-selectall_xml -d genedb /genedb-gene Adh
or:
stag-selectall_xml -d genedb /genedb-gene gene_symbol@=Adh,dpp,bam,indy
so how do you signal "hey this is a template"? the syntactic shorthand is a slash in front of the template name β in this case the template is called genedb-gene. you can also just use the -t option if slashes aren't your vibe.
all the remaining arguments get passed in as SQL template parameters, okay? and they can come in as either name=value pairs, or as a simple list of arguments that get passed into the template in order. either way works, do what feels right π«Ά
to use templates, you should have the environment variableDBSTAG_TEMPLATE_DIRSset. seeDBIx::DBStagfor details. π
π LISTING AVAILABLE TEMPLATES FOR A DB π
stag-selectall_xml -d mydb -h
β LISTING VARIABLES FOR A TEMPLATE β
stag-selectall_xml /genedb-gene -h
π ENVIRONMENT VARIABLES π
DBSTAG_DBIMAP_FILEβ a file containing configuration details for local databases. your local database lore lives here πDBSTAG_TEMPLATE_DIRSβ list of directories (separated by:s) to be searched when templates are requested. yes, colons. plural. π
π COMMAND LINE ARGUMENTS π
-h|helpβ shows this page if no other arguments are given.
if a template is specified, gives template details.
if a db is specified, lists templates for that db.
use in conjunction with -v for full descriptions. (iykyk π)
-d|dbname DBNAMEβ this is either a full DBI locator string (egdbi:Pg:dbname=mydb;host=localhost) or it can also be a shortened "nickname", which is then looked up in the file pointed at by the environment variableDBSTAG_DBIMAP_FILE. nicknames are lowkey iconic ngl.-u|user USERβ database user identity. who are you bestie π«Ά-p|password PASSβ database password. shhh π€«-f|file SQLFILEβ this is a path to a file containing SQL that will be executed, as an alternative to writing the SQL on the command line. write it in a file, serve it fresh π-n|nesting NESTING-EXPRESSIONSβ a bracketed expression indicating how to the resulting objects/XML should be nested. seeDBIx::DBStagfor details. (yes, the original says "how to the resulting" β we keep the facts EXACTLY as they are, periodt. π )-t|template TEMPLATE-NAMEβ the name of a template; see above. β¬οΈ-wh|where WHERE-CLAUSEβ used to override the WHERE clause of the query; useful for combining with templates.
you can append to an existing where clause by using the prefix +. little plus sign, big power. β¨
-s|select SELECT-COLSβ used to override the SELECT clause of the query; useful for combining with templates.-rowsβ sometimes it is preferable to return the results as a table rather than xml or a similar nested structure. specifying-rowswill fetch a table, one line per row, and columns separated by tabs. tab-separated realness π-pre SQLβ a piece of SQL is that is executed immediately before the main query; e.g.:
-pre "SET search_path=myschema,public"
-o|out FILEβ a file to output the results to. redirection but make it fancy π-w|writer WRITERβ writer class; can be any perl class, or one of these:xml[default]sxprβ lisp S-Expressionsitextβ indented text
-colorβ shows results in color (sxpr and itext only). π aesthetic output alert π-showβ will show the parse of the SQL statement. see the SQL's inner thoughts π§
and that's the whole page bestie!! you ate that π«Άβ¨
this masterpiece was brought to you by perl v5.36.0, dated 2022-10-14, from the SELECTALL_XML(1p) girlies themselves. mwah π see you in the next manpage, no cap. π
π¦ where this page comes from
- ubuntu noble: libdbix-dbstag-perl 0.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-dbstag-perl 0.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-dbstag-perl 0.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms