Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
apocalypse committed Dec 11, 2008
0 parents commit 8b1b698
Show file tree
Hide file tree
Showing 38 changed files with 2,717 additions and 0 deletions.
164 changes: 164 additions & 0 deletions Changes
@@ -0,0 +1,164 @@
Revision history for Perl extension POE::Component::SimpleDBI.

* 1.22

Kwalitee-related fixes

* 1.21

silence warnings when used with DBD::SQLite - thanks to Sjors Gielen for tracking this down!

* 1.20

Added the INSERT_ID to control $dbh->last_insert_id usage

* 1.19

Added the PREPARE_CACHED argument to control caching

* 1.18

Ignore the DBI error for last_insert_id and default to undef

* 1.17

Added "INSERTID" to the result of DO

* 1.16

Noticed a glaring documentation bug
- SINGLE queries return mixedCaps rows ( not lowercase! )
- MULTIPLE queries return lowercase rows

This makes me *VERY* tempted to fix SINGLE to return lowercase, is this a good idea? Let me know!

Fixed SimpleDBI failure on Win32 - thanks RT #23851

* 1.15

Thanks to Fred Castellano, who stumbled on a DEADLOCK bug, fixed!
Added sanity tests to CONNECT/DISCONNECT

* 1.14

learned about the difference between ref $self and ref( $self )
Kwalitee-related fixes

* 1.13

Finally use a Changes file - thanks RT #18981
Fixed a bug in SINGLE if returned_rows = 0 it will not return undef, but give us blank rows!
Documentation tweaks

* 1.12

In the SubProcess, added a binmode() to STDIN and STDERR, for the windows attempt
Added code to make SimpleDBI work in Win32 boxes, thanks to the recent Wheel::Run patches!
Documentation tweaks as usual

* 1.11

Hannes had a problem:
His IRC bot logs events to a database, and sometimes there is no events to log after
hours and hours of inactivity ( must be a boring channel haha ), the db server disconnected!

The solution was to do a $dbh->ping() before each query, if your DBI driver does it inefficiently, go yell at them!
In the event that a reconnect is not possible, an error will be sent to the CONNECT event handler, look at the updated pod.

* 1.10

Fixed a bug in the DO routine, thanks to Hannes!

* 1.09

Removed the abstract LIMIT 1 to the SINGLE query

Removed the silly 5.8.x requirement in Makefile.PL

Made the SubProcess use less memory by exec()ing itself

Added the new CONNECT/DISCONNECT commands

Removed the db connection information from new()

Minor tweaks here and there to not stupidly call() the queue checker when there is nothing to check :)

Added the sysreaderr debugging output

More intelligent SQL/PLACEHOLDERS/BAGGAGE handling

Made the command arguments more stricter, it will only accept valid arguments, instead of just extracting what it needs

Made sure all return data have ID/EVENT/SESSION/ACTION in them for easy debugging

Added the SESSION parameter to all commands for easy redirection

Updated the POD and generally made it better :)

Added a new command -> Clear_Queue ( clears the queue )

* 1.08

In the SubProcess, removed the select statement requirement

* 1.07

In the SubProcess, fixed a silly mistake in DO's execution of placeholders

Cleaned up a few error messages in the SubProcess

Peppered the code with *more* DEBUG statements :)

Replaced a croak() with a die() when it couldn't connect to the database

Documented the _child events

* 1.06

Fixed some typos in the POD

Added the BAGGAGE option

* 1.05

Fixed some typos in the POD

Fixed the DEBUG + MAX_RETRIES "Subroutine redefined" foolishness

* 1.04

Got rid of the EVENT_S and EVENT_E handlers, replaced with a single EVENT handler

Internal changes to get rid of some stuff -> Send_Query / Send_Wheel

Added the Delete_Query event -> Deletes an query via ID

Changed the DO/MULTIPLE/SINGLE/QUOTE events to return an ID ( Only usable if call'ed )

Made sure that the ACTION key is sent back to the EVENT handler every time

Added some DEBUG stuff :)

Added the CHANGES section

Fixed some typos in the POD

* 1.03

Increments refcount for querying sessions so they don't go away

POD formatting

Consolidated shutdown and shutdown_NOW into one single event

General formatting in program

DB connection error handling

Renamed the result hash: RESULTS to RESULT for better readability

SubProcess -> added DBI connect failure handling

* 1.02

Initial release
18 changes: 18 additions & 0 deletions MANIFEST
@@ -0,0 +1,18 @@
Makefile.PL
MANIFEST
MANIFEST.SKIP
README
lib/POE/Component/SimpleDBI.pm
lib/POE/Component/SimpleDBI/SubProcess.pm
t/1_load.t
t/a_kwalitee.t
t/a_pod.t
t/a_strict.t
t/a_hasversion.t
t/a_minimumversion.t
t/a_podcoverage.t
t/a_manifest.t
t/a_distribution.t
META.yml Module meta-data (added by MakeMaker)
Changes
examples/db.pl
27 changes: 27 additions & 0 deletions MANIFEST.SKIP
@@ -0,0 +1,27 @@
^.includepath
^.project
^.settings/

# Avoid version control files.
\B\.svn\b

# Avoid Makemaker generated and utility files.
\bMANIFEST\.SKIP
\bMakefile$
\bblib/
\bMakeMaker-\d
\bpm_to_blib$

# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/

# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$

# our tarballs
\.tar\.gz$
Empty file added META.yml
Empty file.
36 changes: 36 additions & 0 deletions Makefile.PL
@@ -0,0 +1,36 @@
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'POE::Component::SimpleDBI',
'VERSION_FROM' => 'lib/POE/Component/SimpleDBI.pm', # finds $VERSION
'PREREQ_PM' => {
'POE' => '0.20',
'POE::Filter::Line' => 0,
'POE::Filter::Reference' => 0,
'POE::Session' => 0,
'POE::Wheel::Run' => 0,

'DBI' => '1.30',
'Error' => '0.15',

# test stuff
'Test::More' => 0,
'Test::Distribution' => 0,
'Test::Strict' => 0,
'Test::HasVersion' => 0,
'Test::CheckManifest' => 0,
'Test::Kwalitee' => 0,
'Test::MinimumVersion' => 0,
'Test::Pod' => 0,
'Test::Pod::Coverage' => 0,
'Test::UseAllModules' => 0,
},
( $] >= 5.005 ? # Add new keywords
(
'ABSTRACT_FROM' => 'lib/POE/Component/SimpleDBI.pm', # retrieve abstract from module
'AUTHOR' => 'Apocalypse <APOCAL@cpan.org>',
'LICENSE' => 'perl',
) : ()
),
);
Binary file added POE-Component-SimpleDBI-1.03.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.04.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.05.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.06.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.07.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.08.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.09.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.10.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.11.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.12.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.13.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.14.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.15.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.16.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.17.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.18.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.19.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.20.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.21.tar.gz
Binary file not shown.
Binary file added POE-Component-SimpleDBI-1.22.tar.gz
Binary file not shown.
23 changes: 23 additions & 0 deletions README
@@ -0,0 +1,23 @@
POE/Component/SimpleDBI
=======================

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

This module is a breeze to use, you'll have DBI calls in your POE program
up and running in only a few seconds of setup.

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

INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make test
make install

MORE INFO

# After installing:
perldoc POE::Component::SimpleDBI
72 changes: 72 additions & 0 deletions examples/db.pl
@@ -0,0 +1,72 @@
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' => [ 38 ],
'EVENT' => 'deleted_handler',
);

# 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
my $id = $_[KERNEL]->call( 'SimpleDBI', 'MULTIPLE',
'SQL' => 'SELECT foo, baz FROM FooTable2 WHERE id = ?',
'PLACEHOLDERS' => [ 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
},
);

# Run POE!
POE::Kernel->run();
exit;

0 comments on commit 8b1b698

Please sign in to comment.