XML_RDB(3pm)

πŸ“¦
version 0.05 Β· 2 versions
  • 0.05 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.05 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 XML_RDB β€” the DBIx::XML_RDB era πŸ’…

okay bestie, sit down, hydrate, and let me tell you about DBIx::XML_RDB β€” the Perl extension (that's 3pm, a Perl module, we love her) that turns your boring old DBI datasource into gorgeous XML. no cap. ✨


✨ NAME ✨

DBIx::XML_RDB β€” a Perl extension for creating XML from existing DBI datasources. it's giving database-to-XML glow-up. πŸ¦‹


✨ SYNOPSIS ✨

look at her go, fr fr:

use DBIx::XML_RDB;
my $xmlout = DBIx::XML_RDB->new($datasource,
              "ODBC", $userid, $password, $dbname) || die "Failed to make new xmlout";
$xmlout->DoSql("select * from MyTable");
print $xmlout->GetData;

like… iconic. copy, paste, slay. πŸ’–


✨ DESCRIPTION ✨

so basically this module is a simple creator of XML data from DBI datasources. it lets you easily extract data from a database, and then manipulate it later using XML::Parser. chef's kiss. πŸ‘‘

one use of this module might be (and will be soon from me, apparently, says the author) to extract data on the web server, and send the raw data (in XML format) to a client's browser, and then use either XML::Parser from PerlScript, or MSXML from VBScript/JavaScript on the client's machine to generate HTML. heads up though: obviously this relies upon using MS IE for their Active Scripting Engine, and MSXML comes with IE5beta. so like, it's giving 2001 core. 😭

another use is a simple database extraction tool, which is included, called sql2xml. this tool simply dumps a table in a database to an XML file. this can be used in conjunction with xml2sql (part of the XML::DBI(?) package β€” yes the question mark is canon, i don't make the rules) to transfer databases from one platform or database server to another. ✈️

binary data is encoded using UTF-8. this is automatically decoded when parsing with XML::Parser. no manual decoding required, we love a self-sufficient queen. πŸ’…

included with the distribution is a "Scriptlet" β€” this is basically a Win32 OLE wrapper around this class, allowing you to call this module from any application that supports OLE. to install it:

  1. first install the scriptlets download from microsoft at http://msdn.microsoft.com/scripting.
  2. then right-click on XMLDB.sct in explorer and select "Register".
  3. create your object as an instance of "XMLDB.Scriptlet".

periodt. that's the whole ritual. πŸŽ€


✨ FUNCTIONS ✨

🌈 new

new ( $datasource, $dbidriver, $userid, $password [, $dbname] )

see the DBI documentation for what each of these means, bestie β€” except for $dbname, which is there for support of Sybase and MSSQL server database names (using use $dbname). special guest parameter energy. 🫢

🌈 DoSql

DoSql ( $sql )

takes a simple Sql command string. it can be either a select statement, or on some DBMS's it can be a stored procedure call that returns a result set β€” Sybase and MSSql support this, and honestly? the author doesn't know about the others. πŸ™ˆ

this doesn't do any checking if the sql is valid. if it fails, the procedure will "die". so if you care about that, wrap it in an eval{} block β€” that's not a vibe suggestion, that's a survival tip. πŸ’€

the result set will be appended to the output. subsequent calls to DoSql don't overwrite the output, rather they append to it. this allows you to call DoSql multiple times before getting the output (via GetData()). stacking results like a true main character. πŸ”₯

🌈 GetData

simply returns the XML generated from this SQL call. unfortunately it doesn't stream out as yet. the author may add this in sometime in the future (this will probably mean an IO handle being passed to new()). so like, manifesting streaming, but not today. ✨

the format of the XML output is something like this:

<?xml version="1.0"?>
<DBI driver="dbi:Sybase:database=foo">
        <RESULTSET statement="select * from Table">
                <ROW>
                <Col1Name>Data</Col1Name>
                <Col2Name>Data</Col2Name>
                ...
                </ROW>
                <ROW>
                ...
                </ROW>
        </RESULTSET>
        <RESULTSET statement="select * from OtherTable">
        ...
        </RESULTSET>
</DBI>

this is quite easy to parse using XML::Parser. clean, structured, gorgeous. 🌸


✨ AUTHOR ✨

Matt Sergeant, matt@sergeant.org β€” the original icon, we stan. πŸ’œ


✨ SEE ALSO ✨

  • XML::Parser β€” your next stop, bestie. go read her too. πŸ¦‹

and that's the whole page, babe β€” this was perl v5.34.0, dated 2022-06-13, and it lives in the XML_RDB(3pm) manpage of the User Contributed Perl Documentation collection. go forth and generate some XML, you absolute legend. πŸ’–βœ¨πŸŽ€