DBIx::QueryByName

Execute SQL queries by name
Download

DBIx::QueryByName Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Erwan Lemonnier
  • Publisher web site:
  • http://search.cpan.org/~erwan/Sub-Contract-0.09/lib/Sub/Contract.pm

DBIx::QueryByName Tags


DBIx::QueryByName Description

Execute SQL queries by name DBIx::QueryByName is a Perl module that allows you to decouple SQL code from Perl code by replacing inline SQL queries with method calls.The idea is to write the code of your SQL queries somewhere else than in your perl code (in a XML file for example) and let DBIx::QueryByName load those SQL declarations and generate methods to execute each query as a usual object method call.This module also implements automatic database session recovery and query retry, when it is deemed safe to do so. It was specifically designed to be used as a high availability interface against a cluster of replicated postgres databases running behind one service IP.DBIx::QueryByName can manage multiple database connections and is fork safe.SYNOPSIS use DBIx::QueryByName; my $dbh = DBIx::QueryByName->new(); # define 2 database connections $dbh->connect("db1", "dbi:Pg:dbname=mydb;host=127.0.0.1;port=6666", $username, $password); $dbh->connect("db2", "dbi:SQLite:/path/to/db/file"); # load some default queries to run against db1 my $queries = INSERT INTO jobs (id, username, description, status) VALUES (?,?,?,0)< /query > < query name="get_job_count" params="" >SELECT COUNT(*) FROM jobs< /query > __ENDQ__ $dbh->load(session => 'db1', from_xml => $queries); # load some default queries to run against db2, from an xml file $dbh->load(session => 'db1', from_xml_file => $filepath); # now run some queries: # insert a few rows in db1.jobs $dbh->add_job( { id => 12, username => "tom", description => "catch mouse" } ); $dbh->add_job( { id => 13, username => "jerry", description => "run away from cat" } ); # count the number of rows: my $sth = $dbh->get_job_count(); # then do what you usually do with a statement handler... Requirements: · Python


DBIx::QueryByName Related Software