Storm::Source(3)

πŸ“¦
version 0.240 Β· 2 versions
, in fedora 43

πŸ’– Storm::Source πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation manual, and it's literally about Storm::Source β€” the class that always produces active database handles on request. no cap. it's giving "your dbh is always ready, always hydrated, never ghosting you" energy. 🫢


✨ NAME ✨

Storm::Source β€” always produces active database handles on request πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe, copy-paste ready:

use Storm::Source;

$source = Storm::Source->new(['DBI:mysql:database:3306', 'user', 'pass']);

$source = Storm::Source->new('@file.txt|record');

$dbh = $source->dbh;

like… three ways in and one way out. iconic honestly. ⭐


🌸 DESCRIPTION 🌸

so Storm::Source objects will return an active database handle on request. that's the whole personality. when you ask, you receive. πŸ‘‘

the handle gets created using connection information stored internally, and β€” plot twist β€” that connection information can easily be retrieved from formatted ascii files. so you can keep your creds in a lil text file and let the object handle it. periodt. πŸ’–


πŸ¦‹ METHODS πŸ¦‹

this class has the following methods:

πŸ’œ $class->new(\@connect_info)

the values inside \@connect_info are passed on to DBI->connect to create a database handler when one is requested. that's it, that's the whole job. you hand over the arrayref, it does the connecting when the time comes. 🧚

πŸ’œ $class->new('@file.txt|record')

you can also load the @connect_info arguments from a text file. the constructor will recognize anytime it is called with a singular argument starting with the @ character β€” that's your lil signal that it's file-loading time. πŸ“βœ¨

the format of the file containing the connect arguments is:

  • one record per line
  • record name and connect args separated with a pipe character
  • the individual connect arguments separated by tab characters

EX:

record1|DBI:mysql:database:address:3306|username|password
record2|DBI:SQLite:dbname=:memory:

see how record1 gets a full mysql connect string plus user and pass, and record2 just casually spins up an in-memory SQLite? lowkey obsessed. 😭πŸ”₯

πŸ’œ $source->dbh

if the $source object is aware of an active database connection, it will be returned. otherwise, a new database handler will be created from DBI->connect. so either way you're getting a handle β€” that's the main character energy we talked about. πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Jeffrey Ray Hallock, <jeffrey dot hallock at gmail dot com>

(they wrote it, we respect it 🫑)


Copyright 2010 Jeffrey Ray Hallock, All Rights Reserved.

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

fr fr, same terms as Perl itself β€” that's the whole license, bestie. go wild, just keep the terms. πŸ’–

and that's the page!! πŸ’€ this shipped with perl v5.42.0 and was dated 2025-07-25 β€” so yeah, it's giving "still relevant, still slaying." mwah, bye bestie!! πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from