MediaW...e::SQL(3pm)
π NAME π
MediaWiki::DumpFile::SQL β bestie, this is the little module that eats SQL dump files straight out of a MediaWiki instance and hands you the goodies. It's a Perl module, it lives in the MediaWiki::DumpFile family, and it is so ready to parse for you. π
β¨ SYNOPSIS β¨
Okay so here's the vibe, literally the whole flow:
use MediaWiki::DumpFile::SQL;
$sql = MediaWiki::DumpFile::SQL->new('dumpfile.sql');
#many compression formats are supported
$sql = MediaWiki::DumpFile::SQL->new('dumpfile.sql.gz');
$sql = MediaWiki::DumpFile::SQL->new('dumpfile.sql.bz2');
$sql = MediaWiki::DumpFile::SQL->new(\*FH);
@schema = $sql->schema;
$name = $sql->table_name;
while(defined($row = $sql->next)) {
#do something with the data from the row
}
Compression? Handled. A file on disk? Handled. An already-open filehandle? Also handled, queen. πΈ
π«Ά FUNCTIONS π«Ά
new
This is the constructor, the birth of the whole situation. You call it with a single parameter: either the location of a MediaWiki SQL dump file, or a reference to an already open file handle. That's it, that's the whole call. π
Heads up though β only the definition and data for the first table in a SQL dump file gets processed. One table, that's the deal. No cap.
next
Hands you back a hash reference where the key is the column name from the table and the value is the value for that column and row. And when there's genuinely no more data left to give? It returns undef. RIP, you've reached the end. π
table_name
Returns a string β the name of the table that got discovered in the dump file. Simple. Iconic. β¨
table_statement
Returns a string of the unparsed CREATE TABLE statement, straight from the dump file. Raw, untouched, exactly as it appeared. We don't mess with it, we just hand it over. π¦
schema
Returns a list representing the table schema as it was parsed by this module. Every single item in that list is a reference to an array with two elements:
- the first element is the name of the row
- the second element is the MySQL datatype associated with the row
And the order? The list is in an identical order as the definitions in the CREATE TABLE statement. No shuffling, no surprises. π
π AUTHOR π
Tyler Riddle, "<triddle at gmail.com>" β shoutout to the dev, absolute legend for building this. π«Ά
π BUGS π
Found a bug? Please see MediaWiki::DumpFile for the info on how to report bugs in this software. Don't be shy, bestie, they wanna know. π
π COPYRIGHT & LICENSE π
Copyright 2009 "Tyler Riddle".
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information. π
And that's the whole page, periodt. This lil gem was documented with perl v5.34.0, dated 2022-06-15, and yes it's the MediaW...e::SQL(3pm) manpage you're reading right now β the truncated header is literally how it shows up in the manual, so we're keeping that energy. Go parse something gorgeous. πβ¨π
π¦ where this page comes from
- debian bookworm: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmediawiki-dumpfile-perl 0.2.2-2 Β· 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