Databa...mpTruck(3pm)
π Database::DumpTruck π
okay so bestie, picture this: Database::DumpTruck β literally a relaxing interface to SQLite πΈ. Yes, the manpage header says Databa...mpTruck(3pm) and that's the vibe, that's the whole energy, the name got a lil nap in the middle. We move. β¨
π SYNOPSIS π
my $dt = new Database::DumpTruck;
$dt->insert({Hello => 'World'});
$dt->create_index(['Hello']);
$dt->upsert({Hello => 'World', Yolo => 8086});
my $data = $dt->dump;
$dt->insert([
{Hello => 'World'},
{Hello => 'Hell', Structured => {
key => value,
array => [ 1, 2, 3, {} ],
}}], 'table2');
my $data2 = $dt->dump('table2');
$dt->drop('table2');
$dt->execute('SELECT 666');
my @columns = $dt->column_names();
$dt->save_var('number_of_the_beast', 666);
my $number_of_the_beast = $dt->get_var('number_of_the_beast');
π¦ DESCRIPTION π¦
So basically π
β this is a simple, document-oriented interface to a SQLite database, and it's modelled after Scraperwiki's Python dumptruck module (iykyk). It lets you stash and grab structured data from a database easy (and maybe, like, lowkey inefficient π«Ά) without ever having to touch SQL. No cap. No SQL. None.
The way Database::DumpTruck works is it peeks at your data, figures out what type it is, and picks the right SQLite type for it:
"integer"β for integer values. So it eats8086, but not"8086"and not8086.0. Fr fr, the quotes matter and the decimal matters."real"β for numeric values that aren't integers. This one's for8086.0, but not"8086"and not8086. It's giving "I'm a float and I know it.""bool"β for values that look like the result of a logical statement. There's a crude little check in place for values that are both""and0, or both"1"and1, at the same time. That happens when you've got a comparison or a negation, bestie. π- Wanna force something to look boolean? Prepend it with a double negation, like
"!!0"or"!!1". Periodt.
- Wanna force something to look boolean? Prepend it with a double negation, like
"json text"β used for"ARRAY"and"HASH"references. The values get converted into and back out of JSON strings when youinsertanddump. Structured data stays iconic. β"text"β pretty much everything else. The catch-all queen π
π METHODS π
π new ([params])
Initialize the database handle, slay. It takes an optional hash of params:
dbname(Default:"dumptruck.db") β the database file. That's the one.table(Default:"dumptruck") β the name for the default table.vars_table(Default:"_dumptruckvars") β the name of the variables table.vars_table_tmp(Default:"_dumptruckvarstmp") β the name of the temporary table that gets used when converting the values for the variables table.auto_commit(Default:1) β turns automatic commit on. Leave it be and it just handles it for you, no stress. β¨
πΈ column_names ([table_name])
Hands you back a list of names of all the columns in the table you named β or in the table called dumptruck if you didn't name one. Simple as.
π execute (sql, [params])
Run a raw SQL statement and get structured output back. You can pass optional parameters to fill in the ? placeholders β yes, real ones, exactly like that.
π
commit ()
Commit the outstanding transaction. Super useful when auto_commit is off, bestie.
π¦ close ()
Close the database handle. Honestly? You should not need to call this one explicitly. Let it go, it handles itself. π
β create_index (columns, [table_name], [if_not_exists], [unique])
Creates an optionally unique index on columns in whatever table you point at. You can also tell it to just do nothing if the index already exists β no drama, no error. Iconic behavior honestly.
π create_table (data, table_name, [error_if_exists])
Makes a table, and optionally errors out if the thing already exists. The structure is based on data β but heads up, no data gets inserted. It's just vibes and scaffolding.
π₯ insert (data, [table_name], [upsert])
Insert (and optionally replace) data into the table you name, or into dumptruck. If the table doesn't exist yet, it creates it with the proper structure for you. Main character energy π₯
π upsert (data, [table_name])
Replace data into the table you name, or into dumptruck. Creates the table with the proper structure if it isn't there already.
Equivalent to calling insert with the upsert parameter set to 1. Same thing, shorter name, cuter.
π get_var (key)
Grab a saved value for a given key out of the variable database.
π§ save_var (key, value)
Insert a value for a given key into the variable database. Store it, queen.
π« tables ()
Returns a list of names of all the tables in the database. All of them, no crumbs.
π dump ([table_name])
Returns all the data from the table you named, or from dumptduck β yes, that's spelled dumptduck right there in the manpage, and we respect the typo, it's part of the lore π β all nicely structured for you.
πΊ drop ([table_name])
Drop the given table, or drop dumptruck. Bye bestie π«Ά
π BUGS π
None known. Not a single one. Living rent free. β¨
π SEE ALSO π
- <https://github.com/scraperwiki/dumptruck> β the Python module this one is heavily inspired by. Go pay respects. π
π COPYRIGHT π
Copyright 2014, Lubomir Rintel
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
β¨ AUTHOR β¨
Lubomir Rintel <lkundrak@v3.sk>
okay that's the whole thing, go forth and dump some trucks π
mwah π this was perl v5.36.0, dated 2023-08-01, filed under Databa...mpTruck(3pm) β and that's the whole page, no skips, no cuts, we ate and left no crumbs. π
π¦ where this page comes from
- debian trixie: libdatabase-dumptruck-perl 1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdatabase-dumptruck-perl 1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdatabase-dumptruck-perl 1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdatabase-dumptruck-perl 1.2-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