Data::...lk::DBI(3pm)

πŸ“¦
version 0.11 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

✨ Data::Stream::Bulk::DBI πŸ’…

okay so bestie, welcome to Data::...lk::DBI β€” yes that's the name, the manpage header literally abbreviates it like that, we don't ask questions, we just vibe. It's a Perl module (a 3pm page, if you're keeping score), and it's about pulling rows out of a database a little at a time instead of dragging the whole giant resultset into RAM and crying about it. 🫢


🌸 VERSION 🌸

version 0.11


πŸŽ€ SYNOPSIS πŸŽ€

use Data::Stream::Bulk::DBI;

my $sth = $dbh->prepare("SELECT hate FROM sql"); # very big resultset
$sth->execute;

return Data::Stream::Bulk::DBI->new(
        sth => $sth,
        max_rows => $n, # how many at a time
        slice => [ ... ], # if you want to pass the first param to fetchall_arrayref
);

like. look at it. "SELECT hate FROM sql". whoever wrote that was going through something and honestly? relatable. 😭


πŸ’– DESCRIPTION πŸ’–

So this is one of the implementations of the Data::Stream::Bulk api (yes, "api" lowercase, that's how they wrote it, I'm not touching it), and it works specifically with DBI statement handles. Under the hood it's leaning on "fetchall_arrayref" in DBI.

The whole point: it fetches "max_rows" rows at a time. That defaults to 500. So instead of one terrifying mega-fetch, you get a cute lil steady drip of chunks. N-at-a-time iteration energy. ✨


🌈 ATTRIBUTES 🌈

  • sth β€” the statement handle that we're gonna call "fetchall_arrayref" on. that's it. that's the whole job. πŸ’…
  • slice β€” this gets passed verbatim as the first param to "fetchall_arrayref". bestie, it should usually just be "undef" β€” it's provided for completetness. (that's their spelling, and I love them for it, keeping it. πŸŽ€)
  • max_rows β€” the second param to "fetchall_arrayref". this is the one that controls how big each buffer is. it defaults to 500. πŸ‘‘

πŸ¦‹ METHODS πŸ¦‹

  • get_more β€” see Data::Stream::Bulk::DoneFlag for the whole picture. what it does: it calls "fetchall_arrayref" to grab the next chunk of rows. that's the move. πŸ”₯
  • all β€” calls "fetchall_arrayref" to get the raminder of the data β€” and yes, "raminder", that's the typo, I am not fixing it, it's part of the family now β€” and importantly it does this without specifying "max_rows". so it's the "gimme everything left" button. πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Yuval Kogman <nothingmuch@woobling.org>


This software is copyright (c) 2012 by Yuval Kogman.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, you ate that, go forth and stream your rows in chunks like the main character you are πŸ’…βœ¨

signing off from perl v5.32.0, dated 2021-01-01, on the page Data::...lk::DBI(3pm) β€” mwah, bye bestie πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from