DataSo...Driver(3pm)

πŸ“¦
version 0.02 Β· 2 versions
  • 0.02 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.02 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– DataSo...Driver(3pm) β€” Driver Writer's Guide and base class πŸ’–

okay bestie, welcome to the User Contributed Perl Documentation section, manual page DataSo...Driver(3pm) β€” this is the glow-up guide for anyone writing a DBIx::DataSource driver. it's the base class AND the instruction manual, which is honestly giving teacher-and-student at the same time and we love a multitasker πŸ’…


✨ NAME ✨

DBIx::DataSource::Driver β€” the Driver Writer's Guide and base class, all in one iconic lil package πŸŽ€


🌸 SYNOPSIS 🌸

first of all, you can just read the whole thing like this:

perldoc DBIx::DataSource::Driver;

or, if you're ready to actually be the driver (main character energy fr fr), you subclass it like this:

package DBIx::DataSource::FooBase;
use DBIx::DataSource::Driver;
@ISA = qw( DBIx::DataSource::Driver );

that's it. that's the whole vibe check βœ…


πŸ¦‹ DESCRIPTION πŸ¦‹

so you wanna implement a driver for your database? slay. here's the tea, and there are exactly two routes, so pick your fighter:

  1. If you can create a database with an SQL command through DBI/DBD, simply provide a parse_dsn class method which returns a list consisting of the actual data source to use in DBI->connect and the SQL. (note the emphasis on actual β€” the real one, not the fake one, bestie 😭)
package DBIx::DataSource::NewDatabase;
use DBIx::DataSource::Driver;
@ISA = qw( DBIx::DataSource::Driver );

sub parse_dsn {
  my( $class, $action, $dsn ) = @_;

  # $action is `create' or `drop'
  # for example, if you parse parse $dsn for $database,
  # $sql = "$action $database";

  # you can die on errors - it'll be caught

  ( $new_dsn, $sql );
}

couple things to clock here, no cap:

  • $action is create or drop β€” that's the whole range, that's the assignment
  • the comment really does say "if you parse parse $dsn for $database" β€” yes, twice, that's how it's written, i'm not fixing it, i'm just reporting it πŸ’€
  • you can die on errors and it's fine, because it'll be caught 🫢
  1. Otherwise, you'll need to write create_database and drop_database class methods. your turn to do the work, bestie:
package DBIx::DataSource::NewDatabase;

sub create_database {
  my( $class, $dsn, $user, $pass ) = @_;

  # for success, return true
  # for failure, die (it'll be caught)
}

sub drop_database {
  my( $class, $dsn, $user, $pass ) = @_;

  # for success, return true
  # for failure, die (it'll be caught)
}

the contract is chef's kiss simple:

  • for success, return true βœ…
  • for failure, die β€” and again, it'll be caught, so you're safe 🧚

πŸ‘‘ AUTHOR πŸ‘‘

Ivan Kohler <ivan-dbix-datasource@420.am> β€” the original icon, we stan πŸ’œ


Copyright (c) 2000 Ivan Kohler Copyright (c) 2000 Mail Abuse Prevention System LLC All rights reserved.

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

like... free software AND same terms as Perl itself? generous queen behavior honestly πŸŽ€


πŸ’€ BUGS πŸ’€

this section is literally empty. not "no known bugs", not a list, just… nothing. the void. the silence. do with that information what you will πŸ™ˆ

⭐ SEE ALSO ⭐

  • DBIx::DataSource
  • DBIx::DataSource::mysql
  • DBIx::DataSource::Pg
  • DBI

go read those next, iykyk πŸ“šβœ¨


and that's the whole page bestie β€” this was perl v5.34.0, dated 2022-06-13, straight out of the DataSo...Driver(3pm) files. go forth and write that driver, you're gonna eat πŸ”₯πŸ’…

πŸ“¦ where this page comes from