<?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>Seán Hayes&#039; Blog &#187; sqlite</title>
	<atom:link href="http://seanhayes.name/tag/sqlite/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanhayes.name</link>
	<description>Web Developer</description>
	<lastBuildDate>Tue, 20 Jul 2010 14:51:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using a Test Database in Django</title>
		<link>http://seanhayes.name/2010/01/09/test-database-django/</link>
		<comments>http://seanhayes.name/2010/01/09/test-database-django/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 14:27:07 +0000</pubDate>
		<dc:creator>Seán Hayes</dc:creator>
				<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[test database]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://seanhayes.name/?p=132</guid>
		<description><![CDATA[As I mentioned in my previous post, we&#8217;re using MySQL on our development machines. It has several advantages, but one of the drawbacks is unittests run slower when not using Sqlite (big ups to MockSoul for posting his benchmarks). The &#8230; <a href="http://seanhayes.name/2010/01/09/test-database-django/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in <a title="Cross Database Incompatibility Using Django South" href="/2010/01/09/cross-database-incompatibility/">my previous post</a>, we&#8217;re using MySQL on our development machines. It has several advantages, but one of the drawbacks is <a title="#8138 (Switch django tests to use transactions)" href="http://code.djangoproject.com/ticket/8138#comment:34">unittests run slower when not using Sqlite</a> (big ups to MockSoul for posting his benchmarks). The reason for this is when running unittests in Django with a Sqlite database, the database is run in memory (RAM) instead of being written to the disk.</p>
<p>Django only allows you to specify one database, and although a new database is created for unittests, <a href="http://docs.djangoproject.com/en/dev/topics/testing/#the-test-database">it still uses most of the same settings</a> (auto prepending &#8220;test_&#8221; to the database name), which means a Django install using MySQL also uses MySQL for unittests.</p>
<p>To get around this problem, I created a file in my project root called test_settings.py containing the following lines:<br />
<script src="http://gist.github.com/269919.js?file=test_settings.py"></script></p>
<p>I then opened my settings.py, imported sys, and inserted the following lines at the end of the file:<br />
<script src="http://gist.github.com/269919.js?file=settings.py"></script></p>
<p>If one of the command line arguments is &#8220;test&#8221;, that means a unittest is being run, in which case Django will attempt to import test_settings.py, which will override the database settings and use Sqlite instead. Migrations won&#8217;t be an issue, since Django South uses the old syncdb command for generating databases for unittests.</p>
<p>Hope this helps you save some time testing.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://seanhayes.name/2010/01/09/cross-database-incompatibility/" title="Cross Database Incompatibility Using Django South (Saturday, January 9, 2010)">Cross Database Incompatibility Using Django South</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://seanhayes.name/2010/01/09/test-database-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Database Incompatibility Using Django South</title>
		<link>http://seanhayes.name/2010/01/09/cross-database-incompatibility/</link>
		<comments>http://seanhayes.name/2010/01/09/cross-database-incompatibility/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 14:11:12 +0000</pubDate>
		<dc:creator>Seán Hayes</dc:creator>
				<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[incompatibility]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[south]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://seanhayes.name/?p=128</guid>
		<description><![CDATA[When our team (at Govnex) started using South Migrations we encountered a cross-database compatibility issue. I was using MySQL on my local machine for its performance and so I could browse the database using phpMyAdmin, while our other members were &#8230; <a href="http://seanhayes.name/2010/01/09/cross-database-incompatibility/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When our team (at Govnex) started using South Migrations we encountered a cross-database compatibility issue. I was using MySQL on my local machine for its performance and so I could browse the database using phpMyAdmin, while our other members were using Sqlite on their local machines. The problem we encountered was migrations that worked my machine running MySQL were failing on their machines running Sqlite. We discovered the cause was some NOT NULL fields in our models which didn&#8217;t have defaults defined; the NOT NULL fields with no defaults were working fine in Sqlite when created using syncdb, so apparently it&#8217;s only when <em>updating</em> a table in Sqlite that they require defaults (this a caveat of Sqlite, not Django South).</p>
<p>Our immediate solution was to add default values to the necessary fields. However, in the end we decided to switch to MySQL on our development machines in order to ensure no future issues arise that might prevent our development code from working on our production server, which also runs MySQL. Hope this helps anyone who might be having the same issue.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://seanhayes.name/2010/01/09/test-database-django/" title="Using a Test Database in Django (Saturday, January 9, 2010)">Using a Test Database in Django</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://seanhayes.name/2010/01/09/cross-database-incompatibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->