<?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>treibsand.com &#187; SQLite</title>
	<atom:link href="http://www.treibsand.com/tag/sqlite/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.treibsand.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Dec 2011 12:46:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Postfix SQLite Readme wieder online</title>
		<link>http://www.treibsand.com/2008/04/30/postfix-sqlite-readme-wieder-online/</link>
		<comments>http://www.treibsand.com/2008/04/30/postfix-sqlite-readme-wieder-online/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 15:23:39 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Mail]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://test.treibsand.com/?p=121</guid>
		<description><![CDATA[Mit der ersten Veröffentlichung des Postfix SQLite Patches habe ich ein HowTo ins Netz gestellt, da ich aber zeitlich nicht mehr dazu gekommen bin die Seite zu pflegen, habe ich sie wieder offline genommen. Endlich hatte ich wieder Zeit, das HowTo und die Manpage auf den neuesten Stand zu bringen. Jetzt ist alles wieder unter [...]]]></description>
			<content:encoded><![CDATA[<p>Mit der ersten Veröffentlichung des Postfix SQLite Patches habe ich ein HowTo ins Netz gestellt, da ich aber zeitlich nicht mehr dazu gekommen bin die Seite zu pflegen, habe ich sie wieder offline genommen. </p>
<p><span id="more-121"></span><br />
Endlich hatte ich wieder Zeit, das HowTo und die Manpage auf den neuesten Stand zu bringen. Jetzt ist alles wieder unter <a href="http://www.treibsand.com/postfix-sqlite/">http://www.treibsand.com/postfix-sqlite/</a> online.</p>
<p>Have fun <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2008/04/30/postfix-sqlite-readme-wieder-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite zu MySQL konvertieren</title>
		<link>http://www.treibsand.com/2008/02/15/sqlite_mysql/</link>
		<comments>http://www.treibsand.com/2008/02/15/sqlite_mysql/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 14:48:07 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://test.treibsand.com/?p=82</guid>
		<description><![CDATA[Es kann vorkommen, dass man ein kleines Projekt beginnt und der Einfachheit halber eine SQLite Datenbank dafuer verwendet. Mit der Zeit wachst aber der Datenbestand und SQLite ist dann damit überfordert. Da Hilft nur noch die Datenbank in ein performanteres System zu migrieren, z.B. MySQL. Allerdings gibt es dabei ein kleines Problem. Die SQLite Dumps [...]]]></description>
			<content:encoded><![CDATA[<p>Es kann vorkommen, dass man ein kleines Projekt beginnt und der Einfachheit halber eine SQLite Datenbank dafuer verwendet. Mit der Zeit wachst aber der Datenbestand und SQLite ist dann damit überfordert. </p>
<p><span id="more-82"></span><br />
Da Hilft nur noch die Datenbank in ein performanteres System zu migrieren, z.B. MySQL. Allerdings gibt es dabei ein kleines Problem.</p>
<p>Die SQLite Dumps sind nicht kompatibel mit MySQL, so dass man erst den Dump konvertieren muss. Für den Fall hilft ein kleines Script aus:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
<span style="color: #008000;">file</span> = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">file</span> = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'(CREATE (TABLE|INDEX)[^;]*|COMMIT|BEGIN TRANSACTION);'</span>, <span style="color: #483d8b;">''</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">file</span> = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'INSERT INTO &quot;([^&quot;]+)&quot;'</span>, <span style="color: #ff7700;font-weight:bold;">lambda</span> m: <span style="color: #483d8b;">'INSERT INTO `%s`'</span> <span style="color: #66cc66;">%</span> m.<span style="color: black;">groups</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Damit lässt sich der Dump wie folgt konvertieren:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>sqlite2mysql <span style="color: #000000; font-weight: bold;">&lt;</span> sqlite_dump.sql <span style="color: #000000; font-weight: bold;">&gt;</span> mysql_dump_dataonly.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2008/02/15/sqlite_mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Postfix SQLite lookup table</title>
		<link>http://www.treibsand.com/2006/10/18/postfix_sqlite/</link>
		<comments>http://www.treibsand.com/2006/10/18/postfix_sqlite/#comments</comments>
		<pubDate>Wed, 18 Oct 2006 11:54:10 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Mail]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://test.treibsand.com/2006/10/18/postfix-sqlite-lookup-table-2/</guid>
		<description><![CDATA[Oft braucht man für Postfix Konfigurationen für virtuelle Accounts. Die übliche Methode hierfür ist z.B. die Konfiguration mit MySQL zu machen. In vielen Fällen rentiert es sich aber nicht gleich einen MySQL Server aufzusetzen. Vor kurzem brauchte ich ein Backend für Postfix, welches wenig Speicher verbraucht und ich per Webinterface einfach verwalten kann. Per Webinterface [...]]]></description>
			<content:encoded><![CDATA[<p>Oft braucht man für Postfix Konfigurationen für virtuelle Accounts. Die übliche Methode hierfür ist z.B. die Konfiguration mit MySQL zu machen. In vielen Fällen rentiert es sich aber nicht gleich einen MySQL Server aufzusetzen.</p>
<p><span id="more-35"></span><br />
Vor kurzem brauchte ich ein Backend für Postfix, welches wenig Speicher verbraucht und ich per Webinterface einfach verwalten kann. Per Webinterface ein lookup table in Form eine Datei zu editieren und danach ein postmap aufzurufen, macht nicht wirklich spass. Aus diesem Grund kam für mich eigentlich nur SQLite in Frage.</p>
<p>Allerdings kann Postfix aktuell keine lookup tables in SQLite Datenbank, deswegen habe ich diese selber eingebaut. Der Patch für Postfix 2.3.3 ist unter http://www.treibsand.com/static/files/postfix-2.3.3_sqlite.patch verfügbar.</p>
<p>Sobald Postfix mit SQLite gebaut ist, sollte man eine Datenbank anlegen, die z.B. wie folgt aufgebaut ist:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> mail_domains <span style="color: #66cc66;">&#40;</span>id <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">DOMAIN</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;  
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> mail_users <span style="color: #66cc66;">&#40;</span>id <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span> email <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">128</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> maildir <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">DOMAIN</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;  
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> mail_virtual<span style="color: #66cc66;">&#40;</span> id <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span> email <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> destination text<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">DOMAIN</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>In der Datei main.cf kann wie folgt auf die lookup table zugegriffen werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">virtual_mailbox_maps = sqlite:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>sqlite-mailbox.cf
virtual_mailbox_domains = sqlite:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>sqlite-domains.cf
virtual_alias_maps = sqlite:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>sqlite-alias.cf</pre></div></div>

<p>Jede Config Datei für SQLite muss 2 Anweisungen enthalten:</p>
<ul>
<li>dbpath &#8211; Pfad zur SQLite Datenbank</li>
<li>query &#8211; SQL Query</li>
</ul>
<p>Eine Config Datei kann z.B. wie folgt aussehen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>aliases.db
query = SELECT forw_addr FROM mxaliases WHERE <span style="color: #007800;">alias</span>=<span style="color: #ff0000;">'%s'</span> AND <span style="color: #007800;">status</span>=<span style="color: #ff0000;">'active'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2006/10/18/postfix_sqlite/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ProFTP mit SQLite Backend</title>
		<link>http://www.treibsand.com/2006/08/03/proftp-mit-sqlite-backend/</link>
		<comments>http://www.treibsand.com/2006/08/03/proftp-mit-sqlite-backend/#comments</comments>
		<pubDate>Thu, 03 Aug 2006 21:28:38 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ProFTP]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://test.treibsand.com/2009/01/15/proftp-mit-sqlite-backend/</guid>
		<description><![CDATA[Was tun, wenn man einige User für einen FTP Server hat, allerdings keine Systembenutzer einrichten möchte? Der freie FTP Server ProFTP unterstützt zwar MySQL Und PostgreSQL Backends, aber die sind gar nicht nötig, wenn es nur um eine Handvoll von Benutzern geht. Da ProFTP selber über eine Modul Schnittstelle verfügt ist es kein Problem diese [...]]]></description>
			<content:encoded><![CDATA[<p>Was tun, wenn man einige User für einen FTP Server hat, allerdings keine Systembenutzer einrichten möchte? Der freie FTP Server ProFTP unterstützt zwar MySQL Und PostgreSQL Backends, aber die sind gar nicht nötig, wenn es nur um eine Handvoll von Benutzern geht.</p>
<p><span id="more-9"></span><br />
Da ProFTP selber über eine Modul Schnittstelle verfügt ist es kein Problem diese Funktionalität einzubauen. Unter http://www.castaglia.org/proftpd/modules/mod_sql_sqlite.html gibt es genau für diesen Fall ein passendes Modul <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Sobald das Modul mit einkompiliert ist, kann das Backend in der proftpd.conf wie folgt angesprochen werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_sql_sqlite.c<span style="color: #000000; font-weight: bold;">&gt;</span>
  SQLConnectInfo <span style="color: #000000; font-weight: bold;">/</span>pfad<span style="color: #000000; font-weight: bold;">/</span>zu<span style="color: #000000; font-weight: bold;">/</span>ftpd.db
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Mehr ist für die Verbindung zur Datenbank nicht nötig. Da ProFTP selber schon eine Schnittstelle für SQL hat, kann die Abfrage der Benutzer mit mod_sql gemacht werden. Eine Anleitung hierfür ist unter http://www.castaglia.org/proftpd/modules/mod_sql.html zu finden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2006/08/03/proftp-mit-sqlite-backend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

