DBIx::...::Mysql(3pm)
π DBIx::BulkLoader::Mysql β the manual, but make it cute π
okay bestie, welcome to the DBIx::...::Mysql(3pm) page from your friendly neighborhood User Contributed Perl Documentation β¨ this is literally the whole thing, no skips, no cuts, we're reading it together π«Ά
πΈ NAME πΈ
DBIx::BulkLoader::Mysql β Perl extension for mysql bulk loading π
β¨ SYNOPSIS β¨
use DBIx::BulkLoader::Mysql;
# non repeating portion of the insert statement
my $insert='insert into bulk_insert (col_a,col_b,col_c) values ';
# repeating portion of the insert statement
my $placeholders='(?,?,?)';
# how many rows to buffer until insert is called
my $bulk_insert_count=5;
# db connection
my $dbh=DBI->connect(db connection info here);
my $placeholder_count=3;
my ($bulk,$error)=DBIx::BulkLoader::Mysql->new(
dbh=>$dbh
,sql_insert=>$insert
,placeholders=>$placeholders
);
die $error unless $bulk;
for( 1 .. 50 ) {
$bulk->insert(qw(a b c));
}
# inserted 50 rows at once
$bulk->insert(qw(l l x));
# inserted 0 rows
$bulk->insert(qw(l l x));
# inserted 0 rows
$bulk->flush;
# inserted 2 rows 1 at a time
like, the vibe is: buffer a bunch of rows, slam them in all at once, and only do the slow single-row thing at the very end when you flush. iconic behavior tbh π
π DESCRIPTION π
Simple buffering bulk loader interface for mysql. π
π EXPORT π
None. literally nothing. it's giving minimalism, and we respect it π§
π¦ OO Methods π¦
This section covers the OO methods for this package.
my ($bulk,$error)=DBIx::BulkLoader::Mysql->new(%hash);β Package constructor.
$bulk is undef on error
$error explains why $bulk is undef
Constructor options:
dbh=>$dbhβ Sets the DBH object πsql_insert=>$insertβ Contains the body of the sql statement minus the placeholder segment.placeholders=>$placeholdersβ Placeholder segment of the sql statement.placeholder_count=>3β Optional argument. If you get strange insert counts or dbi bails, set this option manually πbulk_insert_count=>50β Optional argument. Sets the number of rows to buffer for insert.prepare_args=>{}β Optional argument. Arguments to be passed to$dbh->prepare. SeeDBD::mysql.
$bulk->flush;β Empties the placeholder buffer π«$bulk->insert($x,$y,$z);β Inserts the placeholder arguments onto the buffer stack. This does not cause an insert, unless the total number of rows is the same as the constructor call"bulk_insert_count=>50". β³my $columns=$bulk->get_placeholder_count;β Gets the total number of column placeholders.my $buffer_size=$bulk->get_buffer_size;β Gets the total size of the array used for insert.my $sql_single=$bulk->single_sql;β Gets the raw sql statement used for single row inserts.my $bulk_sql=$bulk->bulk_sql;β Gets the raw sql statement used for bulk row inserts.my $single_sth=$bulk->get_prepared_single_sth;β Gets the prepared statement handle for single row inserts.my $bulk_sth=$bulk->get_prepared_bulk_sth;β Gets the prepared statement handle for bulk row inserts.my @buffer=$bulk->get_buffered_data;β Returns a list containing the current buffered data. peek at the queue bestie π
π SEE ALSO π
DBI, DBD::mysql
πΈ Source Forge Project πΈ
If you find this software "usefil" (their word, not mine, π love that) please donate to the Source Forge Project.
DBIx BulkLoader Mysql β https://sourceforge.net/projects/dbix-bulkloader/ π
π«Ά AUTHOR π«Ά
Michael Shipper
π COPYRIGHT AND LICENSE π
Copyright (C) 2010 by Michael Shipper
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
okay and that's the whole page, no cap π this was DBIx::...::Mysql(3pm), served up from perl v5.36.0, dated 2023-02-14 β happy valentine's day to bulk inserts and bulk inserts only ππΈ go load some rows bestie, you're gonna slay πβ¨
π¦ where this page comes from
- debian trixie: libdbix-bulkloader-mysql-perl 1.006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdbix-bulkloader-mysql-perl 1.006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-bulkloader-mysql-perl 1.006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-bulkloader-mysql-perl 1.006-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