POE::C...mpleDBI(3pm)

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

πŸ’… POE::Component::SimpleDBI(3pm) πŸ’…

✨ NAME ✨

  • POE::Component::SimpleDBI β€” Asynchronous non-blocking DBI calls in POE made simple

Okay bestie, POE::Component::SimpleDBI is here to make DBI in POE actually not a whole mess. πŸ’–

🌟 VERSION 🌟

This document describes v1.31 of POE::Component::SimpleDBI - released November 05, 2014 as part of POE-Component-SimpleDBI.

πŸ¦‹ SYNOPSIS πŸ¦‹

use POE;
use POE::Component::SimpleDBI;

# Create a new session with the alias we want
POE::Component::SimpleDBI->new( 'SimpleDBI' ) or die 'Unable to create the DBI session';

# Create our own session to communicate with SimpleDBI
POE::Session->create(
        inline_states => {
                _start => sub {
                        # Tell SimpleDBI to connect
                        $_[KERNEL]->post( 'SimpleDBI', 'CONNECT',
                                'DSN'           =>      'DBI:mysql:database=foobaz;host=192.168.1.100;port=3306',
                                'USERNAME'      =>      'FooBar',
                                'PASSWORD'      =>      'SecretPassword',
                                'EVENT'         =>      'conn_handler',
                        );

                        # Execute a query and return number of rows affected
                        $_[KERNEL]->post( 'SimpleDBI', 'DO',
                                'SQL'           =>      'DELETE FROM FooTable WHERE ID = ?',
                                'PLACEHOLDERS'  =>      [ qw( 38 ) ],
                                'EVENT'         =>      'deleted_handler',
                                'INSERT_ID'     =>      0,
                        );

                        # Retrieve one row of information
                        $_[KERNEL]->post( 'SimpleDBI', 'SINGLE',
                                'SQL'           =>      'Select * from FooTable LIMIT 1',
                                'EVENT'         =>      'success_handler',
                                'BAGGAGE'       =>      'Some Stuff I want to keep!',
                        );

                        # We want many rows of information + get the query ID so we can delete it later
                        # Furthermore, disable prepare_cached on this query
                        my $id = $_[KERNEL]->call( 'SimpleDBI', 'MULTIPLE',
                                'SQL'           =>      'SELECT foo, baz FROM FooTable2 WHERE id = ?',
                                'PLACEHOLDERS'  =>      [ qw( 53 ) ],
                                'EVENT'         =>      'multiple_handler',
                                'PREPARE_CACHED'=>      0,
                        );

                        # Quote something and send it to another session
                        $_[KERNEL]->post( 'SimpleDBI', 'QUOTE',
                                'SQL'           =>      'foo$*@%%sdkf"""',
                                'SESSION'       =>      'OtherSession',
                                'EVENT'         =>      'quote_handler',
                        );

                        # Changed our mind!
                        $_[KERNEL]->post( 'SimpleDBI', 'Delete_Query', $id );

                        # 3 ways to shutdown

                        # This will let the existing queries finish, then shutdown
                        $_[KERNEL]->post( 'SimpleDBI', 'shutdown' );

                        # This will terminate when the event traverses
                        # POE's queue and arrives at SimpleDBI
                        $_[KERNEL]->post( 'SimpleDBI', 'shutdown', 'NOW' );

                        # Even QUICKER shutdown :)
                        $_[KERNEL]->call( 'SimpleDBI', 'shutdown', 'NOW' );
                },

                # Define your request handlers here
                'quote_handler' =>      \&FooHandler,
                # And so on
        },
);

πŸ’– DESCRIPTION πŸ’–

This module simplifies DBI usage in POE's multitasking world. No cap. ✨

It is a breeze to use β€” you'll have DBI calls in your POE program up and running in only a few seconds of setup. It's giving "effortless main character energy". πŸ’…

This module does what XML::Simple does for the XML world. Periodt.

The way it works its magic? It creates a new session with POE, then spawns off a child process to do the "heavy" lifting. That way, your main POE process can continue servicing other clients. Queries are put into a queue, and processed one at a time. Lowkey genius. 🧚

The standard way to use this module is to do this:

use POE;
use POE::Component::SimpleDBI;

POE::Component::SimpleDBI->new( ... );

POE::Session->create( ... );

POE::Kernel->run();

πŸŽ€ Starting SimpleDBI πŸŽ€

To start SimpleDBI, just call its new method:

POE::Component::SimpleDBI->new( 'ALIAS' );

This method will die on error or return success. So like, vibe check it, bestie.

NOTE: The act of starting/stopping SimpleDBI fires off _child events, read the POE documentation on what to do with them :)

This constructor accepts only 3 arguments.

Alias

This sets the session alias in POE.

The default is "SimpleDBI".

PREPARE_CACHED

This sets the global PREPARE_CACHED setting. This is a boolean value.

POE::Component::SimpleDBI->new( 'ALIAS', 0 );

The default is enabled.

SYNCHRONOUS_MODE

This disables the fork() that the subprocess does. Use this only if you are having issues with the backend and want to debug the database without dealing with multiprocess issues.

POE::Component::SimpleDBI->new( 'ALIAS', 1, 1 );

The default is disabled.

🌈 Commands 🌈

There are a few commands you can trigger in SimpleDBI. They are triggered via $_[KERNEL]->post( ... );

ID

All of the commands except for Delete_Query and shutdown return an id. To get them, do this:

my $id = $_[KERNEL]->call( 'SimpleDBI', ... );

Afterwards, the id can be used to delete queries, look at Delete_Query for more information.

Argument errors

All of the commands validate their arguments, and if an error happens ( missing argument, etc ), they will do either:

  • return undef and forget that your request even existed
  • post to the SESSION/EVENT with ERROR present in the data
NOTE: The data will not have an ID key present

Explanation of DO/SINGLE/MULTIPLE/QUOTE arguments

They are passed in via the $_[KERNEL]->post( ... );

NOTE: Capitalization is very important!
  • "SQL" β€” This is the actual SQL line you want SimpleDBI to execute. You can put in placeholders, this module supports them.
  • "PLACEHOLDERS" β€” This is an array of placeholders.

You can skip this if your query does not utilize it.

  • "SESSION" β€” This is the session that will get the result

You can skip this, it defaults to the sending session

  • "EVENT" β€” This is the event, triggered whenever a query finished.

It will get a hash in ARG0, consult the specific queries on what you will get.

NOTE: If the key 'ERROR' exists in the hash, then it will contain the error string.
  • "BAGGAGE" β€” This is a special argument, you can "attach" any kind of baggage to a query. The baggage will be kept by SimpleDBI and returned to the Event handler intact.

This is good for storing data associated with a query like a client object, etc.

You can skip this if your query does not utilize it.

  • "PREPARE_CACHED" β€” This was added recently, to override SimpleDBI's default behavior of using the $dbh->prepare_cached() function. Setting this to false will use $dbh->prepare() instead.

Some users reported problems with PostgreSQL. After investigation, this turned out to be some bizarre OID caching issues when the table was updated while the connection is alive. The quick work-around is to reconnect to the database, but this was not a "sane" solution.

This is a simple boolean value, and if this argument does not exist, SimpleDBI will use the global setting when calling new().

  • "INSERT_ID" β€” This was added recently, to override SimpleDBI's default behavior of using the $dbh->last_insert_id() function. Setting this to false will disable retrieval of this value.

This is a simple boolean value, and if this argument does not exist, SimpleDBI will default to true.

"CONNECT"

This tells SimpleDBI to connect to the database. NOTE: if we are already connected, it will be a success ( SimpleDBI will not disconnect then connect automatically ). Accepted arguments:

  • DSN β€” The DBI DSN string, consult the DBI docs on what this is
  • USERNAME β€” The username for the connection
  • PASSWORD β€” The password for the connection
  • SESSION β€” The session to send the results
  • EVENT β€” The event to send the results
  • NOW β€” Tells SimpleDBI to bypass the queue and connect NOW!
  • CLEAR β€” Tells SimpleDBI to clear the queue and connect NOW!
  • AUTO_COMMIT β€” The boolean value we will pass to DBI->connect ( defaults to true )
  • CACHEDKIDS β€” Controls the method to cache prepare_cached queries, an arrayref ( defaults to undef )
  • BAGGAGE β€” Any extra data to keep associated with this query ( SimpleDBI will not touch it )
NOTE: if the DSN/USERNAME/PASSWORD/SESSION/EVENT does not exist, SimpleDBI assumes you wanted to use the old connection and will use the cached values ( if you told it to DISCONNECT ). Here's an example on how to trigger this event:
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT',
        'DSN'           =>      'DBI:mysql:database=foobaz;host=192.168.1.100;port=3306',
        'USERNAME'      =>      'MyUser',
        'PASSWORD'      =>      'MyPassword',
        'EVENT'         =>      'conn_handler',
        'NOW'           =>      1,
);

The NOW/CLEAR arguments are special, they will tell SimpleDBI to bypass the request queue and connect NOW... The CLEAR argument will also delete all the requests waiting in the queue, they will get an ERROR result. They both default to false, supply a boolean value to turn them on. The Event handler will get a hash in ARG0:

...and the hash it hands you in ARG0 looks like this, bestie:

{
        'ERROR'         =>      exists only if an error occured
        'GONE'          =>      exists only if the server was disconnected and the reconnect failed
        'ACTION'        =>      'CONNECT'
        'ID'            =>      ID of the Query
        'EVENT'         =>      The event the query will respond to
        'SESSION'       =>      The session the query will respond to
}

okay but the genuinely iconic part πŸ’… is that you can stack these up and they all go down in the right order, like a little queue of main-character tasks:

# NOTE: You can do nifty things like this. They all will be executed in the right order!
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT', 'DSN' => 'DBI:mysql:...', ... );
$_[KERNEL]->post( 'SimpleDBI', 'DO', ... );
$_[KERNEL]->post( 'SimpleDBI', 'SINGLE', ... );
$_[KERNEL]->post( 'SimpleDBI', 'DISCONNECT' );
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT', 'DSN' => 'DBI:oracle:...', ... );
$_[KERNEL]->post( 'SimpleDBI', 'MULTIPLE', ... );
$_[KERNEL]->post( 'SimpleDBI', 'shutdown' );

As of 1.11 SimpleDBI now lowkey detects whether the backend lost its connection to the database server 😭. The backend will automatically reconnect if that happens β€” but if the reconnect fails, an error gets sent to the session/event you specified, and it comes with an extra lil key: 'GONE'. When you're in this state, SimpleDBI is deadlocked β€” like, any new queries will not be processed until a CONNECT NOW event is issued! 🫠 And keep this in mind: the SINGLE/etc queries WILL NOT receive an error if this happens. The error goes straight to the CONNECT handler, to keep it simple!

fr fr, remember that one β€” deadlocked SimpleDBI is not the vibe. πŸ’€

As of 1.29 SimpleDBI added better control of the prepare_cached cache. Some users reported that the subprocess' memory usage was leaking, and in extreme cases it reached several gigs 😳! Upon investigation, it was not SimpleDBI's fault β€” it's just how DBI works. What DBI does is cache the statement handle from $dbh->prepare_cached in the $dbh handle. The problem? It stays around forever in the default implementation! πŸ™ˆ Perusing the DBI docs revealed that it was possible to tie this cache to a custom cache module. So they added the CACHEDKIDS argument, and setting it to an arrayref enables the behavior. Look at <http://search.cpan.org/dist/DBI/DBI.pm#prepare_cached> for more info. Here's an example, bestie:

$_[KERNEL]->post( 'SimpleDBI', 'CONNECT', ..., 'CACHEDKIDS' => [ 'Tie::Cache::LRU' ] );

The first element in the array is the module to use when tying the cache. Any additional elements get passed to the module's constructor. So go look at the docs for your fave cache module! πŸ’– If users report success with this, in a future version of SimpleDBI it might become the default behavior. Keep in mind that this will be redundant if PREPARE_CACHED == 0.


πŸ’” "DISCONNECT" πŸ’”

This tells SimpleDBI to disconnect from the database. NOTE: if a DISCONNECT is issued when we are not connected, it will still succeed! ✨ Accepted arguments:

SESSION         ->      The session to send the results
EVENT           ->      The event to send the results
NOW             ->      Tells SimpleDBI to bypass the queue and disconnect NOW!
CLEAR           ->      Tells SimpleDBI to clear the queue and disconnect NOW!
BAGGAGE         ->      Any extra data to keep associated with this query ( SimpleDBI will not touch it )

Here's an example on how to trigger this event:

$_[KERNEL]->post( 'SimpleDBI', 'DISCONNECT',
        'EVENT'         =>      'disconn_handler',
        'NOW'           =>      1,
);

The NOW/CLEAR arguments are special β€” they tell SimpleDBI to bypass the request queue and connect NOW. The CLEAR argument will also delete all the requests waiting in the queue, and those get an ERROR result. They both default to false, so supply a boolean value to turn them on. The Event handler will get a hash in ARG0:

{
        'ERROR'         =>      exists only if an error occured
        'ACTION'        =>      'DISCONNECT'
        'ID'            =>      ID of the Query
        'EVENT'         =>      The event the query will respond to
        'SESSION'       =>      The session the query will respond to
}
BEWARE: there is the possibility of a deadlock! πŸ’€ In this case, the DO/SINGLE queries will NEVER run until you issue a CONNECT with NOW enabled at the end! Not me warning you twice, but like... I warned you:
# BEWARE: There is the possibility of a deadlock! In this case, the DO/SINGLE queries will
# NEVER run until you issue a CONNECT with NOW enabled at the end!
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT', ... );
$_[KERNEL]->post( 'SimpleDBI', 'MULTIPLE', ... );
$_[KERNEL]->post( 'SimpleDBI', 'DISCONNECT' );
$_[KERNEL]->post( 'SimpleDBI', 'DO', ... );
$_[KERNEL]->post( 'SimpleDBI', 'SINGLE', ... );
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT' );

πŸ’¬ "QUOTE" πŸ’¬

This simply sends off a string to be quoted, and gets it back. So simple, so clean, we love her πŸŽ€ Accepted arguments:

SESSION         ->      The session to send the results
EVENT           ->      The event to send the results
SQL             ->      The string to be quoted
BAGGAGE         ->      Any extra data to keep associated with this query ( SimpleDBI will not touch it )

Internally, it does something like this:

return $dbh->quote( $SQL );

Here's an example on how to trigger this event:

$_[KERNEL]->post( 'SimpleDBI', 'QUOTE',
        SQL => 'foo$*@%%sdkf"""',
        EVENT => 'quote_handler',
);

The Event handler will get a hash in ARG0:

{
        'ERROR'         =>      exists only if an error occured
        'ACTION'        =>      'QUOTE'
        'ID'            =>      ID of the Query
        'EVENT'         =>      The event the query will respond to
        'SESSION'       =>      The session the query will respond to
        'SQL'           =>      Original SQL inputted
        'RESULT'        =>      The quoted SQL
        'PLACEHOLDERS'  =>      Original placeholders ( may not exist if it was not provided )
        'BAGGAGE'       =>      whatever you set it to ( may not exist if it was not provided )
}

πŸ› οΈ "DO" πŸ› οΈ

This query is specialized for those queries where you UPDATE/DELETE/INSERT/etc. THIS IS NOT FOR SELECT QUERIES! πŸ™…β€β™€οΈ Accepted arguments:

SESSION         ->      The session to send the results
EVENT           ->      The event to send the results
SQL             ->      The string to be quoted
PLACEHOLDERS    ->      Any placeholders ( if needed )
BAGGAGE         ->      Any extra data to keep associated with this query ( SimpleDBI will not touch it )
PREPARE_CACHED  ->      Boolean value ( if needed )
INSERT_ID       ->      Boolean value ( if needed )

Internally, it does something like this:

$sth = $dbh->prepare_cached( $SQL );
$rows_affected = $sth->execute( $PLACEHOLDERS );
return $rows_affected;

Here's an example on how to trigger this event:

$_[KERNEL]->post( 'SimpleDBI', 'DO',
        SQL => 'DELETE FROM FooTable WHERE ID = ?',
        PLACEHOLDERS => [ 38 ],
        EVENT => 'deleted_handler',
);

The Event handler will get a hash in ARG0:

{
        'ERROR'         =>      exists only if an error occured
        'ACTION'        =>      'DO'
        'ID'            =>      ID of the Query
        'EVENT'         =>      The event the query will respond to
        'SESSION'       =>      The session the query will respond to
        'SQL'           =>      Original SQL inputted
        'RESULT'        =>      Scalar value of rows affected
        'PLACEHOLDERS'  =>      Original placeholders ( may not exist if it was not provided )
        'BAGGAGE'       =>      whatever you set it to ( may not exist if it was not provided )
        'INSERTID'      =>      The insert ID - using $dbh->last_insert_id( undef, undef, undef, undef ) [ defaults to undef ]
}

🌟 "SINGLE" 🌟

This query is specialized for those queries where you will get exactly 1 result back. One. Uno. The main character of rows πŸ’… Accepted arguments:

SESSION         ->      The session to send the results
EVENT           ->      The event to send the results
SQL             ->      The string to be quoted
PLACEHOLDERS    ->      Any placeholders ( if needed )
BAGGAGE         ->      Any extra data to keep associated with this query ( SimpleDBI will not touch it )
PREPARE_CACHED  ->      Boolean value ( if needed )

Internally, it does something like this:

$sth = $dbh->prepare_cached( $SQL );
$sth->execute( $PLACEHOLDERS );
$result = $sth->fetchrow_hashref;
return $result;

Here's an example on how to trigger this event:

$_[KERNEL]->post( 'SimpleDBI', 'SINGLE',
        SQL => 'Select * from FooTable',
        EVENT => 'success_handler',
        SESSION => 'MySession',
);

The Event handler will get a hash in ARG0:

{
        'ERROR'         =>      exists only if an error occured
        'ACTION'        =>      'SINGLE'
        'ID'            =>      ID of the Query
        'EVENT'         =>      The event the query will respond to
        'SESSION'       =>      The session the query will respond to
        'SQL'           =>      Original SQL inputted
        'RESULT'        =>      Hash of columns - similar to fetchrow_hashref ( undef if no rows returned )
        'PLACEHOLDERS'  =>      Original placeholders ( may not exist if it was not provided )
        'BAGGAGE'       =>      whatever you set it to ( may not exist if it was not provided )
}

🌈 "MULTIPLE" 🌈

This query is specialized for those queries where you will get more than 1 result back.

WARNING! The column names are all lowercased automatically! WARNING! πŸ‘‘

Accepted arguments:

SESSION         ->      The session to send the results
EVENT           ->      The event to send the results
SQL             ->      The string to be quoted
PLACEHOLDERS    ->      Any placeholders ( if needed )
BAGGAGE         ->      Any extra data to keep associated with this query ( SimpleDBI will not touch it )
PREPARE_CACHED  ->      Boolean value ( if needed )

Internally, it does something like this:

$sth = $dbh->prepare_cached( $SQL );
$sth->execute( $PLACEHOLDERS );
$sth->bind_columns( \( @$newdata{ @{ $sth->{'NAME_lc'} } } ) );
while ( $sth->fetch() ) {
        push( @results, { @$newdata } );
}
return \@results;

okay bestie so here's literally how you trigger this event πŸ’«

$_[KERNEL]->post( 'SimpleDBI', 'MULTIPLE',
    SQL => 'SELECT foo, baz FROM FooTable2 WHERE id = ?',
    EVENT => 'multiple_handler',
    PLACEHOLDERS => [ 53 ],
    PREPARE_CACHED => 0,
);

and your event handler is gonna get a whole hash dropped into ARG0, like:

{
    'ERROR'        =>    exists only if an error occured
    'ACTION'    =>    'MULTIPLE'
    'ID'        =>    ID of the Query
    'EVENT'        =>    The event the query will respond to
    'SESSION'    =>    The session the query will respond to
    'SQL'        =>    Original SQL inputted
    'RESULT'    =>    Array of hash of columns - similar to array of fetchrow_hashref's ( undef if no rows returned )
    'PLACEHOLDERS'    =>    Original placeholders ( may not exist if it was not provided )
    'BAGGAGE'    =>    whatever you set it to ( may not exist if it was not provided )
}

πŸ’₯ "ATOMIC" πŸ’₯

okay so this one is specifically for the queries you need to run inside a transaction, no cap. You hand over an array of SQL queries and SimpleDBI runs all of them inside one transaction block. You do NOT have to stress about AutoCommit, BEGIN, or END TRANSACTION β€” it's all handled, bestie 🫢

You're supposed to pass in an array of queries that would normally be run as a DO-style query. And again β€” you CANNOT run SELECT queries with this type of command! Also rn there's no control over prepare_cached for individual queries. It might get added in a future release, we'll see πŸ’…

⚠️ WARNING: this one tripped me up big time while testing β€” it worked on Postgres but not MySQL, and I was so confused 😭 then I remembered I was testing against MyISAM tables, which doesn't support transactions! (it works beautifully on InnoDB tables hah). So if this doesn't "behave" properly for you, please please please check your database tables!! πŸ™ˆ

Accepted arguments, bestie:

  • SESSION -> the session to send the results to
  • EVENT -> the event to send the results to
  • SQL -> the array of SQL queries
  • PLACEHOLDERS -> the array of placeholders ( if needed ) [ this is an AoA - array of arrays! ]
  • BAGGAGE -> any extra data to keep associated with this query ( SimpleDBI will not touch it )
  • PREPARE_CACHED -> Boolean value ( if needed ) [ for all of the queries! ]

internally it does something like this, jsyk:

eval {
    $dbh->begin_work;
    for my $idx ( 0 .. $#array ) {
        if ( $prepare_cached ) {
            $sth = $dbh->prepare_cached( $array[ $idx ] );
        } else {
            $sth = $dbh->prepare( $array[ $idx ] );
        }
        if ( defined $PLACEHOLDERS[ $idx ] ) {
            $sth->execute( $PLACEHOLDERS[ $idx ] );
        } else {
            $sth->execute;
        }
        $sth->finish;
    }
    $dbh->commit;
};
if ( $@ ) {
    eval { $dbh->rollback };
    if ( $@ ) {
        return ROLLBACK_FAILURE;
    } else {
        return COMMIT_FAILURE;
    }
} else {
    return SUCCESS;
}

and here's an example on how to trigger this event πŸŽ€

$_[KERNEL]->post( 'SimpleDBI', 'ATOMIC',
    SQL => [
        'DELETE FROM FooTable WHERE ID = ?',
        'UPDATE FooTable SET baz = ? WHERE bar = ?',
    ],
    EVENT => 'atomic_handler',
    PLACEHOLDERS => [    [ 53 ],
                [ 5, 86 ]
    ],
);

the event handler gets a hash in ARG0:

{
    'ERROR'        =>    exists only if an error occured ( ROLLBACK_FAILURE or COMMIT_FAILURE with explanation )
    'ACTION'    =>    'ATOMIC'
    'ID'        =>    ID of the Query
    'EVENT'        =>    The event the query will respond to
    'SESSION'    =>    The session the query will respond to
    'SQL'        =>    Original SQL array inputted
    'RESULT'    =>    Either SUCCESS or in case of error, not exists
    'PLACEHOLDERS'    =>    Original placeholders ( may not exist if it was not provided )
    'BAGGAGE'    =>    whatever you set it to ( may not exist if it was not provided )
}

πŸ—‘οΈ "Delete_Query" πŸ—‘οΈ

call this event if you wanna delete a query by its ID, iconic. It returns:

undef if it wasn't able to find the ID
0 if the query is currently being processed
1 if the query was successfully deleted

here's how you trigger it:

$_[KERNEL]->post( 'SimpleDBI', 'Delete_Query', $queryID );

IF you really wanna know the status, do a call on the event and check the returned value πŸ‘‘

🧹 "Clear_Queue" 🧹

this event clears the entire queue β€” except the running query, if there is one. So like, it's not gonna yank the thing that's mid-execution, ok bestie πŸ’…

you can also pass in one argument -> the error string to be used instead of the default, 'Cleared the queue'

all the queries sitting in the queue will return ERROR to their respective sessions/events πŸ“£

πŸ›‘ "shutdown" πŸ›‘

this signals SimpleDBI to start the shutdown procedure. With no arguments, SimpleDBI will wait for outstanding queries to finish before killing its session 🫢

you can also pass an argument to ignore those queries and halt immediately:

$_[KERNEL]->post( 'SimpleDBI', 'shutdown', 'NOW' );

but ngl, due to the way POE's queue works, this shutdown event takes some time to propagate through POE's queue. So if you REALLY want it down immediately, do this:

$_[KERNEL]->call( 'SimpleDBI', 'shutdown', 'NOW' );

✨ SimpleDBI Notes ✨

this module is very picky about capitalization! like it will not let it slide πŸ’€

all of the options are UPPERCASE, to avoid confusion.

you can enable debugging mode by doing this:

sub POE::Component::SimpleDBI::DEBUG () { 1 }
use POE::Component::SimpleDBI;

also, this module will try to keep the SubProcess alive. if it dies, it will open it again for a max of 5 retries.

you can override this behavior by doing this:

sub POE::Component::SimpleDBI::MAX_RETRIES () { 10 }
use POE::Component::SimpleDBI;

🧬 DBI attributes 🧬

since SimpleDBI doesn't expose the DBI handle, it might be an issue if you need to set custom attributes. but fear not bestie β€” DBI already has a standard mechanism for this: "connection attribute values" in "#connect" in DBI. here's an example to enable utf8 for a Postgres database:

$_[KERNEL]->post( 'SimpleDBI', 'CONNECT',
    'DSN'        =>    'DBI:Pg(pg_enable_utf8=>1):host=foo;dbname=bar',
    ...
);

🌈 SEE ALSO 🌈

please see those modules/websites for more information related to this module, bestie 🫢

  • DBI
  • POE::Component::DBIAgent
  • POE::Component::LaDBI
  • POE::Component::EasyDBI

πŸ’– SUPPORT πŸ’–

okay bestie, you're not alone in this. here's every single way to get help, and i mean every single one 🫢

πŸ“– Perldoc

you can find the docs for this module with the perldoc command, like:

perldoc POE::Component::SimpleDBI

🌐 Websites

these websites have more info about this module and might lowkey save your life. but fr fr, as always β€” in addition to those websites, please use your favorite search engine to discover more resources ✨

πŸ“§ Email

you can email the author of this module at APOCAL at cpan.org asking for help with any problems you have πŸ’Œ

πŸ’¬ Internet Relay Chat

you can get live help by using IRC ( Internet Relay Chat ). if you don't know what IRC is, please read this excellent guide: <http://en.wikipedia.org/wiki/Internet_Relay_Chat>. please be courteous and patient when talking to us, because we might be busy or sleeping! 😴 you can join those networks/channels and get help:

  • irc.perl.org β€” you can connect to the server at 'irc.perl.org' and join this channel: #perl-help then talk to this person for help: Apocalypse.
  • irc.freenode.net β€” you can connect to the server at 'irc.freenode.net' and join this channel: #perl then talk to this person for help: Apocal.
  • irc.efnet.org β€” you can connect to the server at 'irc.efnet.org' and join this channel: #perl then talk to this person for help: Ap0cal.

πŸ› Bugs / Feature Requests

please report any bugs or feature requests by email to bug-poe-component-simpledbi at rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-SimpleDBI>. you will be automatically notified of any progress on the request by the system. iconic behaviour honestly πŸ‘‘

πŸ’» Source Code

the code is open to the world, and available for you to hack on. please feel free to browse it and play with it, or whatever. if you want to contribute patches, please send me a diff or prod me to pull from your repository :)

<https://github.com/apocalypse/perl-poe-simpledbi>

git clone https://github.com/apocalypse/perl-poe-simpledbi.git

πŸ‘‘ AUTHOR

Apocalypse <APOCAL@cpan.org>

🌈 CONTRIBUTORS

  • Apocalypse <apoc@blackhole.(none)>
  • Apocalypse <apoc@satellite.(none)>
  • Rocco Caputo <rcaputo@cpan.org>

this software is copyright (c) 2014 by Apocalypse.

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

the full text of the license can be found in the LICENSE file included with this distribution. go read it bestie, it's short i promise πŸ’…


⚠️ DISCLAIMER OF WARRANTY

okay so this part is in ALL CAPS and that's because it's the serious part. no skipping πŸ’€

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

and that's a wrap on the whole page, bestie!! πŸŽ€ this rendition was rendered by perl v5.42.0 on 2025-07-25, and honestly? she ate. go forth and query your databases asynchronously, you absolute main character πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from