Rex::Gr...kup::DBI(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ’– Rex::Group::Lookup::DBI(3) πŸ’–

okay so bestie, this is the manual for Rex::Group::Lookup::DBI, straight from the User Contributed Perl Documentation corner of the universe. It's giving "tiny module, big hostgroup energy" and we're gonna read it together.

🌸 NAME 🌸

Rex::Group::Lookup::DBI β€” read hostnames and groups from a DBI source. no cap, that's the whole name vibe.

✨ DESCRIPTION ✨

With this module you can define hostgroups out of a DBI source. That's it, that's the flex. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

use Rex::Group::Lookup::DBI;
groups_dbi "dsn", "user", "password", "SQL request";

🫢 EXPORTED FUNCTIONS 🫢

πŸŽ€ groups_dbi($dsn, $user, $password, $sql) πŸŽ€

This function is how you read groups from a DBI source. Here's the example from the page, with all its named args and the create_all_group => TRUE moment:

groups_dbi( 'DBI:mysql:rex;host=db01',
  user             => 'username',
  password         => 'password',
  sql              => "SELECT * FROM HOST",
  create_all_group => TRUE);

πŸ—„οΈ Database sample for MySQL πŸ—„οΈ

Need a table to make it make sense? This is the sample, exactly as written:

CREATE TABLE IF NOT EXISTS `HOST` (
  `ID` int(11) NOT NULL,
  `GROUP` varchar(255) DEFAULT NULL,
  `HOST` varchar(255) NOT NULL,
  PRIMARY KEY (`ID`)
);

πŸ“ Data sample for MySQL πŸ“

And here's the data sample, also exactly as written β€” look at those little rows go:

INSERT INTO `HOST` (`ID`, `GROUP`, `HOST`) VALUES
  (1, 'db', 'db01'),
  (2, 'db', 'db02'),
  (3, 'was', 'was01'),
  (4, 'was', 'was02');

Source/version + date sign-off, because we don't leave the footer hanging: this page is rockin' perl v5.42.3, dated 2023-08-05, and it's the manual for Rex::Gr...kup::DBI(3). bye bestie, go read some groups πŸ’œβœ¨

πŸ“¦ where this page comes from