<?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>James Henstridge &#187; PostgreSQL</title>
	<atom:link href="http://blogs.gnome.org/jamesh/tag/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/jamesh</link>
	<description>Random stuff</description>
	<lastBuildDate>Tue, 27 Oct 2009 08:48:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Psycopg migrated to Bazaar</title>
		<link>http://blogs.gnome.org/jamesh/2008/04/28/psycopg-migrated-to-bazaar/</link>
		<comments>http://blogs.gnome.org/jamesh/2008/04/28/psycopg-migrated-to-bazaar/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 14:07:50 +0000</pubDate>
		<dc:creator>James Henstridge</dc:creator>
				<category><![CDATA[Uncategorised]]></category>
		<category><![CDATA[Bazaar]]></category>
		<category><![CDATA[Launchpad]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/jamesh/2008/04/28/psycopg-migrated-to-bazaar/</guid>
		<description><![CDATA[Last week we moved psycopg from Subversion to Bazaar.  I did the migration using Gustavo Niemeyer&#8217;s svn2bzr tool with a few tweaks to map the old Subversion committer IDs to the email address form conventionally used by Bazaar.
The tool does a good job of following tree copies and create related Bazaar branches.  It doesn&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>Last week we moved psycopg from <a href="http://subversion.tigris.org/">Subversion</a> to <a href="http://bazaar-vcs.org/">Bazaar</a>.  I did the migration using <a href="http://blog.labix.org/">Gustavo Niemeyer</a>&#8217;s <a href="https://launchpad.net/svn2bzr">svn2bzr</a> tool with a few tweaks to map the old Subversion committer IDs to the email address form conventionally used by Bazaar.</p>
<p>The tool does a good job of following tree copies and create related Bazaar branches.  It doesn&#8217;t have any special handling for stuff in the tags/ directory (it produces new branches, as it does for other tree copies).  To get real Bazaar tags, I wrote a <a href="http://people.ubuntu.com/~jamesh/add-tags.py">simple post-processing script</a> to calculate the heads of all the branches in a tags/ directory and set them as tags in another branch (provided those revisions occur in its ancestry).  This worked pretty well except for a few revisions synthesised by a previous cvs2svn migration.  As these tags were from pretty old psycopg 1 releases I don&#8217;t know how much it matters.</p>
<p>As there is no code browsing set up on initd.org yet, I set up mirrors of the 2.0.x and 1.x branches on <a href="https://launchpad.net/">Launchpad</a> to do this:</p>
<ul>
<li><a href="http://bazaar.launchpad.net/~psycopg/psycopg/2.0.x/">http://bazaar.launchpad.net/~psycopg/psycopg/2.0.x/</a></li>
<li><a href="http://bazaar.launchpad.net/~psycopg/psycopg/1.x/">http://bazaar.launchpad.net/~psycopg/psycopg/1.x/</a></li>
</ul>
<p>It is pretty cool having access to the entire revision history locally, and should make it easier to maintain full credit for contributions from non-core developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/jamesh/2008/04/28/psycopg-migrated-to-bazaar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Psycopg2 2.0.7 Released</title>
		<link>http://blogs.gnome.org/jamesh/2008/04/15/psycopg2/</link>
		<comments>http://blogs.gnome.org/jamesh/2008/04/15/psycopg2/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 06:55:50 +0000</pubDate>
		<dc:creator>James Henstridge</dc:creator>
				<category><![CDATA[Uncategorised]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/jamesh/2008/04/15/psycopg2/</guid>
		<description><![CDATA[Yesterday Federico released version 2.0.7 of psycopg2 (a Python database adapter for PostgreSQL).  I made a fair number of the changes in this release to make it more usable for some of Canonical&#8217;s applications.  The new release should work with the development version of Storm, and shouldn&#8217;t be too difficult to get everything working with [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday Federico <a href="http://lists.initd.org/pipermail/psycopg/2008-April/006013.html">released version 2.0.7 of psycopg2</a> (a <a href="http://www.python.org/">Python</a> database adapter for <a href="http://www.postgresql.org/">PostgreSQL</a>).  I made a fair number of the changes in this release to make it more usable for some of <a href="http://www.canonical.com/">Canonical</a>&#8217;s applications.  The new release should work with the development version of Storm, and shouldn&#8217;t be too difficult to get everything working with other frameworks.</p>
<p>Some of the improvements include:</p>
<ul>
<li>Better selection of exceptions based on the <a href="http://www.postgresql.org/docs/current/static/errcodes-appendix.html">SQLSTATE</a> result field.  This causes a number of errors that were reported as ProgrammingError to use a more appropriate exception (e.g. DataError, OperationalError, InternalError).  This was the change that broke Storm&#8217;s test suite as it was checking for ProgrammingError on some queries that were clearly not programming errors.</li>
<li>Proper error reporting for commit() and rollback(). These methods now use the same error reporting code paths as execute(), so an integrity error on commit() will now raise IntegrityError rather than OperationalError.</li>
<li>The compile-time switch that controls whether the display_size member of Cursor.description is calculated is now turned off by default.  The code was quite expensive and the field is of limited use (and not provided by a number of other database adapters).</li>
<li>New QueryCanceledError and TransactionRollbackError exceptions.  The first is useful for handling queries that are canceled by <a href="http://www.postgresql.org/docs/8.3/static/runtime-config-client.html#GUC-STATEMENT-TIMEOUT">statement_timeout</a>.  The second provides a convenient way to catch serialisation failures and deadlocks: errors that indicate the transaction should be retried.</li>
<li>Fixes for a few memory leaks and GIL misuses. One of the leaks was in the notice processing code that could be particularly problematic for long-running daemon processes.</li>
<li>Better test coverage and a driver script to run the entire test suite in one go.  The tests should all pass too, provided your database cluster uses unicode (there was a report just before the release of one test failing for a LATIN1 cluster).</li>
</ul>
<p>If you&#8217;re using previous versions of psycopg2, I&#8217;d highly recommend upgrading to this release.</p>
<p>Future work will probably involve support for the DB-API two phase commit extension, but I don&#8217;t know when I&#8217;ll have time to get to that.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/jamesh/2008/04/15/psycopg2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Two‐Phase Commit in Python&#8217;s DB‐API</title>
		<link>http://blogs.gnome.org/jamesh/2008/03/04/python-tpc/</link>
		<comments>http://blogs.gnome.org/jamesh/2008/03/04/python-tpc/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 06:19:31 +0000</pubDate>
		<dc:creator>James Henstridge</dc:creator>
				<category><![CDATA[Uncategorised]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Storm]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/jamesh/2008/03/04/python-tpc/</guid>
		<description><![CDATA[Marc uploaded a new revision of the Python DB-API 2.0 Specification yesterday that documents the new two phase commit extension that I helped develop on the db-sig mailing list.
My interest in this started from the desire to support two phase commit in Storm – without that feature there are far fewer occasions where its ability [...]]]></description>
			<content:encoded><![CDATA[<p>Marc uploaded a new revision of the <a href="http://www.python.org/">Python</a> <a href="http://www.python.org/dev/peps/pep-0249/">DB-API 2.0 Specification</a> yesterday that documents the new two phase commit extension that I helped develop on the db-sig mailing list.</p>
<p>My interest in this started from the desire to support two phase commit in <a href="http://storm.canonical.com/">Storm</a> – without that feature there are far fewer occasions where its ability to talk to multiple databases can be put to use.  As I was doing some work on <a href="http://www.initd.org/tracker/psycopg/">psycopg2 </a>for <a href="https://launchpad.net/">Launchpad</a>, I initially put together a <a href="http://www.postgresql.org/">PostgreSQL</a> specific patch, which was (rightly) rejected by Federico.</p>
<p>He suggested that it would be better to try and standardise on an API on the db-sig list, so that&#8217;s what I did.  I looked over the API exposed by other database adapters that supported <acronym title="Two‐Phase Commit">2PC</acronym>, and the 2PC APIs of the major free databases that did not have support in their Python adapters (<a href="http://www.mysql.com/">MySQL</a> and PostgreSQL).  The resulting API is a bit more complicated than my original PostgreSQL-only but has the advantage of being implementable on other databases such as MySQL.</p>
<p>Below is a simple example of using the API directly (missing some of the error handling):</p>
<blockquote>
<pre># begin transactions for each database connection
conn1.tpc_begin(conn1.xid(42, 'transaction ID', 'connection 1'))
conn2.tpc_begin(conn2.xid(42, 'transaction ID', 'connection 2'))
# Do stuff with both connections
...
<strong>try</strong>:
    conn1.tpc_prepare()
    conn2.tpc_prepare()
<strong>except</strong> DatabaseError:
    conn1.tpc_rollback()
    conn2.tpc_rollback()
<strong>else</strong>:
    conn1.tpc_commit()
    conn2.tpc_commit()</pre>
</blockquote>
<p>Or alternatively, if you&#8217;ve got one connection supporting 2PC and the other only supporting one-phase commit, it could be structured as follows:</p>
<blockquote>
<pre># begin transactions for each database connection
conn1.tpc_begin(conn1.xid(42, 'transaction ID', 'connection 1'))
# Do stuff with both connections
...
<strong>try</strong>:
    conn1.tpc_prepare()
    conn2.commit()
<strong>except</strong> DatabaseError:
    conn1.tpc_rollback()
    conn2.rollback()
<strong>else</strong>:
    conn1.tpc_commit()</pre>
</blockquote>
<p>While it is possible to use the 2PC API directly, it is expected that most applications will rely on a transaction manager to coordinate global transactions, such as <a href="http://www.zope.org/">Zope&#8217;s</a> <a href="http://pypi.python.org/pypi/transaction">transaction</a> module.</p>
<p>The hope is that by offering a consistent API, Python application frameworks will be more likely to bother supporting this feature of databases.  Hopefully you&#8217;ll be able to use the API with PostgreSQL and Storm soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/jamesh/2008/03/04/python-tpc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
