<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bluefeet &#187; dbix-class</title>
	<atom:link href="http://blog.bluefeet.net/tag/dbix-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bluefeet.net</link>
	<description>Yet another Perl Hacker weblog</description>
	<lastBuildDate>Thu, 10 Jun 2010 15:22:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Robust DBI Transaction and Connection Handling</title>
		<link>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/</link>
		<comments>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 05:27:25 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[DBIC]]></category>
		<category><![CDATA[dbix-class]]></category>
		<category><![CDATA[DBIx::Class]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=210</guid>
		<description><![CDATA[Edit: It turns out there is already a module on CPAN that does exactly what I talked about here.  Its called DBIx::Connector.  I haven&#8217;t tried it yet, but it looks like the guy that wrote it designed it with input from the DBIC guys.
I&#8217;m a big fan of DBIx::Class.  Among DBIC&#8217;s many [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><b>Edit:</b> It turns out there is already a module on CPAN that does exactly what I talked about here.  Its called <a href="http://search.cpan.org/perldoc?DBIx::Connector">DBIx::Connector</a>.  I haven&#8217;t tried it yet, but it looks like the guy that wrote it designed it with input from the DBIC guys.</p></blockquote>
<p>I&#8217;m a big fan of <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>.  Among DBIC&#8217;s many great features is its superb transaction and connection handling via <a href="http://search.cpan.org/perldoc?DBIx::Class::Storage::DBI">DBIx::Class::Storage::DBI</a>.  When I&#8217;m using raw DBI I feel like I&#8217;m missing these core components.  I should always be able to expect robust transaction and connection handling.</p>
<p>I started playing around with creating a new CPAN module (something like DBIx::Robust, DBIx::Transaction, etc&#8230;) but each time I dove in to it I kept coming to the conclusion that DBIC&#8217;s DBI storage drivers provide everything I need and I would just be shooting myself in the foot by either porting DBIx::Class::Storage::DBI to a DBIC independent API or by writing it from scratch.</p>
<p>Before I go any further, let me show you how attractive and awesome DBIC&#8217;s storage layer is:</p>
<ul>
<li>Transactions may be nested, even without savepoints.</li>
<li>Transaction savepoints can automatically be tracked allowing for reliable and incremental rollbacks.</li>
<li>The appropriate DateTime::Format class is automatically determined based on the type of database.</li>
<li>All database calls efficiently pass through a layer that detects stale connections that will attempt to re-connect to a database.</li>
</ul>
<p><a href="http://images.google.com/images?gbv=2&#038;q=kung+fu+panda+opening&#038;btnG=Search&#038;start=0"><i>&#8220;There is no charge for awesomeness, or attractiveness.&#8221;</i></a></p>
<p>The DBIx::Class::Storage::DBI pod illustrates all this in a round-about way: <i>&#8220;If you set AutoCommit => 0 in your connect info, then you are always in an assumed transaction between commits, and you&#8217;re telling us you&#8217;d like to manage that manually. A lot of the magic protections offered by this module will go away. We can&#8217;t protect you from exceptions due to database disconnects because we don&#8217;t know anything about how to restart your transactions. You&#8217;re on your own for handling all sorts of exceptional cases if you choose the AutoCommit => 0 path, just as you would be with raw DBI.&#8221;</i></p>
<p>This stuff is really powerful, and we should never have to work with databases in Perl without it.  But, currently, it is only meant to work under DBIC, which is a shame.  I&#8217;m betting that DBIx::Class::Storage::DBI could be used directly, bypassing DBIC completely.  There is some DBIC stuff layered in there, but that should be ignorable.</p>
<p>What do the rest of you think?  Has anyone considered moving this logic out in to a generic distribution that isn&#8217;t DBIC specific?  Is there merit in what I&#8217;m talking about?  Does anyone use DBIx::Class::Storage::DBI directly, bypassing DBIC?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
