<?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>Endlessly Curious &#187; SQL</title>
	<atom:link href="http://www.endlesslycurious.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.endlesslycurious.com</link>
	<description>Programming, Productivity &#38; Software Development.</description>
	<lastBuildDate>Mon, 09 Jan 2012 09:00:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using SQLite in Python</title>
		<link>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/</link>
		<comments>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 09:00:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1318</guid>
		<description><![CDATA[Python has had support for SQLite built-in since version 2.5. This is a very convenient pairing as SQLite is an excellent lightweight SQL implementation that I find very useful for a variety of tasks e.g. data mining.  Or any task involving manipulating complex data sets where I&#8217;d otherwise end up resorting to using a full [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Python.org" href="http://python.org/">Python</a> has had <a title="PyDocs" href="http://docs.python.org/library/sqlite3.html">support</a> for <a title="SQLite.org" href="http://sqlite.org/">SQLite</a> built-in since version 2.5.</p>
<p>This is a very convenient pairing as SQLite is an excellent lightweight SQL implementation that I find very useful for a variety of tasks e.g. data mining.  Or any task involving manipulating complex data sets where I&#8217;d otherwise end up resorting to using a full blown SQL server like <a href="http://www.mysql.com/">MySQL</a>.</p>
<p>Here is a simple example of using SQLite in Python using it&#8217;s built-in sqlite3 module:</p>
<pre class="brush: python; title: ; notranslate">
import sqlite3

# craete a connection
con = sqlite3.connect('test.db')

# create a cursor
cur = con.cursor()

# create a test table
cur.execute( &quot;CREATE TABLE testTable (myKey INT, myValue INT)&quot; )

# insert some data
for i in range(0,10):
 cur.execute( &quot;INSERT INTO testTable VALUES ( %d, %d )&quot;%(i,i*i) )

# select the data
for row in cur.execute( &quot;SELECT * FROM testTable&quot; ):
 print row

# destroy (drop) our test table
cur.execute( &quot;DROP TABLE testTable&quot; )

# close the connection
con.close()
</pre>
<p>As you can see Python makes handling SQLite (a C language library) much easier, less error prone, and the resulting code much more compact than SQLite&#8217;s native C.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

