<?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 &#187; mysql</title>
	<atom:link href="http://seanhayes.name/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanhayes.name</link>
	<description>Web Developer in Rochester, NY (Django, JavaScript, LAMP)</description>
	<lastBuildDate>Tue, 06 Mar 2012 01:07:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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[At Govnex 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 reason for this is when &#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>At Govnex 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 type="text/javascript" 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 type="text/javascript" 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. <a title="Cross Database Incompatibility Using Django South" href="http://seanhayes.name/2010/01/09/cross-database-incompatibility/">Migrations won&#8217;t be an issue</a>, since Django South uses the old syncdb command for generating databases for unittests.</p>
<p>Hope this helps you save some time testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanhayes.name/2010/01/09/test-database-django/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

