<?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>sqlite3 Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/sqlite3/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/sqlite3/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Thu, 11 Dec 2025 07:09:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>SQLite3: Python and SQL</title>
		<link>https://creatronix.de/sqlite3-python-and-sql/</link>
					<comments>https://creatronix.de/sqlite3-python-and-sql/#respond</comments>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Thu, 02 Apr 2020 08:57:45 +0000</pubDate>
				<category><![CDATA[Data Science & SQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[sqlite3]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=1323</guid>

					<description><![CDATA[<p>Everything we did in the last articles of the series SQL-Tutorial was a dry run because we just used SQLFiddle. So let&#8217;s start with a real database like SQLite. SQLite is a file based DBRMS and can be used for e.g. web sites. The official docs say: &#8220;SQLite works great as the database engine for&#8230;</p>
<p>The post <a href="https://creatronix.de/sqlite3-python-and-sql/">SQLite3: Python and SQL</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Everything we did in the last articles of the series <a href="https://creatronix.de/sql-tutorial/">SQL-Tutorial</a> was a dry run because we just used SQLFiddle.</p>
<p>So let&#8217;s start with a real database like SQLite.</p>
<p>SQLite is a file based DBRMS and can be used for e.g. web sites. The official docs say:</p>
<p><em>&#8220;SQLite works great as the database engine for most low to medium traffic websites (which is to say, most websites). [..] Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite.&#8221;</em></p>
<p>Because Knight Industries is not Google, Amazon nor Facebook we can definitely use SQLite.</p>
<h2>Creating and connecting to a database</h2>
<p>In Python it is pretty easy to connect to a SQLite database:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>from sqlite3 import connect 
db_connection = connect('knight_industries.db')</code></pre>
</div>
<p>If the file knight_industries.db does not exist, it will be created automagically. A nice little feature of the sqlite3 library.</p>
<p>But be careful: If You already have a database file and you mess up the path in the connect statement you will wonder why you cannot access your data, because a new file is created silently.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>cursor = db_connection.cursor()
cursor.execute('''CREATE TABLE operatives (id INTEGER, name TEXT, birthday DATE)''')
cursor.execute('''INSERT INTO operatives (id, name, birthday) \
                  VALUES (1, "Michael Arthur Long", "1949-01-09")''')

db_connection.commit()
cursor.execute('''SELECT * FROM operatives''')
print cursor.fetchone()
db_connection.close()</code></pre>
</div>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/sqlite3-python-and-sql/">SQLite3: Python and SQL</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://creatronix.de/sqlite3-python-and-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
