<?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>Penguinspeak &#187; SQLite</title>
	<atom:link href="http://macmartine.com/blog/category/sqlite/feed" rel="self" type="application/rss+xml" />
	<link>http://macmartine.com/blog</link>
	<description>This is how I see it.</description>
	<lastBuildDate>Tue, 19 Oct 2010 00:39:03 +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>Lita: SQLite Database Administration</title>
		<link>http://macmartine.com/blog/2009/11/lita-sqlite-database-administration.html</link>
		<comments>http://macmartine.com/blog/2009/11/lita-sqlite-database-administration.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 23:09:40 +0000</pubDate>
		<dc:creator>99miles</dc:creator>
				<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://macmartine.com/blog/?p=175</guid>
		<description><![CDATA[If you need a good (and free!) SQLite Admin, I&#8217;ve been using Lita, created by David Deraedt, for a bit and it&#8217;s been working well. I must admit I mostly use it just for confirmation that my code did what I expected it to, but it seems pretty solid.]]></description>
			<content:encoded><![CDATA[<p>If you need a good (and free!) SQLite Admin, I&#8217;ve been using <a href="http://www.dehats.com/drupal/?q=node/58">Lita</a>, created by David Deraedt, for a bit and it&#8217;s been working well.<br />
I must admit I mostly use it just for confirmation that my code did what I expected it to, but it seems pretty solid.</p>
<p><img alt="" src="http://www.dehats.com/drupal/files/icon_128_2.png" title="Lita: SQLite Database Administration " class="alignnone" width="128" height="128" /></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Lita%3A+SQLite+Database+Administration+http%3A%2F%2Fbit.ly%2F1tenO5" title="Post to Twitter"><img class="nothumb" src="http://macmartine.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://macmartine.com/blog/2009/11/lita-sqlite-database-administration.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resolving gcc errors installing sqlite3 gem on Leopard</title>
		<link>http://macmartine.com/blog/2008/04/resolving_gcc_errors_installin.html</link>
		<comments>http://macmartine.com/blog/2008/04/resolving_gcc_errors_installin.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 14:02:07 +0000</pubDate>
		<dc:creator>99miles</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://macmartine.com/blog/?p=32</guid>
		<description><![CDATA[The following error kept coming up when trying to install Sqlite3 on OS X (actually, the same thing happened when trying to install Fink too). It was finally resolved by installing the latest XCode packages. Running ‘sudo ./configure &#8211;prefix=/usr/local’ would return: checking build system type... i386-apple-darwin9.2.2 checking host system type... i386-apple-darwin9.2.2 checking for gcc... gcc [...]]]></description>
			<content:encoded><![CDATA[<p>The following error kept coming up when trying to install Sqlite3 on OS X (actually, the same thing happened when trying to install Fink too). It was finally resolved by installing the latest XCode packages.<br />
Running ‘sudo ./configure &#8211;prefix=/usr/local’<br />
would return:</p>
<pre name="code" class="css">
checking build system type... i386-apple-darwin9.2.2
checking host system type... i386-apple-darwin9.2.2
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
Here’ all the important stuff from the log:
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2062: checking build system type
configure:2080: result: i386-apple-darwin9.2.2
configure:2102: checking host system type
configure:2117: result: i386-apple-darwin9.2.2
configure:2187: checking for gcc
configure:2203: found /usr/bin/gcc
configure:2214: result: gcc
configure:2452: checking for C compiler version
configure:2459: gcc --version &gt;&amp;5
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:2462: $? = 0
configure:2469: gcc -v &gt;&amp;5
Using built-in specs.
Target: i686-apple-darwin8
Configured with: /private/var/tmp/gcc/gcc-5367.obj~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --with-arch=nocona --with-tune=generic --program-prefix= --host=i686-apple-darwin8 --target=i686-apple-darwin8
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5367)
configure:2472: $? = 0
configure:2479: gcc -V &gt;&amp;5
gcc: argument to `-V' is missing
configure:2482: $? = 1
configure:2505: checking for C compiler default output file name
configure:2532: gcc    conftest.c  &gt;&amp;5
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib unknown flags (type) of section 6 (__TEXT,__literal16) in load command 0
collect2: ld returned 1 exit status
configure:2535: $? = 1
configure:2573: result:
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "sqlite"
| #define PACKAGE_TARNAME "sqlite"
| #define PACKAGE_VERSION "3.5.7"
| #define PACKAGE_STRING "sqlite 3.5.7"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:2580: error: C compiler cannot create executables
See `config.log' for more details.
## ----------- ##
## confdefs.h. ##
## ----------- ##
#define PACKAGE_NAME "sqlite"
#define PACKAGE_TARNAME "sqlite"
#define PACKAGE_VERSION "3.5.7"
#define PACKAGE_STRING "sqlite 3.5.7"
#define PACKAGE_BUGREPORT ""
configure: exit 77
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Resolving+gcc+errors+installing+sqlite3+gem+on+Leopard+http%3A%2F%2Fbit.ly%2F1UMgYZ" title="Post to Twitter"><img class="nothumb" src="http://macmartine.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://macmartine.com/blog/2008/04/resolving_gcc_errors_installin.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Data storage and caching with SQLite databases and Adobe AIR</title>
		<link>http://macmartine.com/blog/2008/02/data_storage_and_caching_with_.html</link>
		<comments>http://macmartine.com/blog/2008/02/data_storage_and_caching_with_.html#comments</comments>
		<pubDate>Tue, 12 Feb 2008 14:45:43 +0000</pubDate>
		<dc:creator>99miles</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://macmartine.com/blog/?p=26</guid>
		<description><![CDATA[You may or may not know by now that the AIR runtime includes a version of SQLite engine. Being a smaller implementation of SQL, SQLite supports all your usual database transactions, a lot of the complex queries, and triggers. With it,you can create a database to store all the data for your Flex/AIR desktop applications, [...]]]></description>
			<content:encoded><![CDATA[<p>You may or may not know by now that the AIR runtime includes a version of SQLite engine. Being a smaller implementation of SQL, SQLite supports all your usual database transactions, a lot of the complex queries, and triggers. With it,you can create a database to store all the data for your Flex/AIR desktop applications, store data for offline use of your Flex/AIR desktop/web applications, or for caching of data. It&#8217;s all done in the same way. I was recently working on an application where I wanted the user to have an option to be logged in automatically when the app was launched, so the first time the user logged in I created a database to cache that login info. From then on when the application is launched it checks to see if the database exists, and if so it grabs the login info, and logs them in automatically.</p>
<p>I&#8217;ve made a simple example which is a super simple desktop application which stores it&#8217;s data in a SQLite database. The idea and implementation here is very similar to what I just described for the caching example. On launch, we first check to see if the database exists. If it does, that means it ought to contain some data so we grab the data and display it. If the database doesn&#8217;t exist, we create it and add our one default entry, then load it into the application. The user can then add, remove, and update entries. When each of these transactions sends a result of success, we reload all the data in the database. Obviously in a real-world application this wouldn&#8217;t be a great idea; that&#8217;s too much overhead. One option would be to just manipulate the dataProvider ArrayCollection after each successful transaction &#8212; but for this simple example I&#8217;m leaving it the way it is for the intent of simply demonstrating using SQLite.</p>
<p>At this point I think I&#8217;ll let the code speak for itself.</p>
<p>ﾠ<br />
Basically you&#8217;ll notice the basic steps are:</p>
<p>1. Create a connection: connection = new SQLConnection();</p>
<p>2. Define the database file: dbFile = File.applicationStorageDirectory.resolvePath(dbFileString);</p>
<p>3. Open (or create and open ) the database: connection.open(dbFile);</p>
<p>4. Create an empty SQLStatement: var sql : SQLStatement = new SQLStatement();</p>
<p>5. Create a query: var sqlString : String = &#8220;CREATE TABLE Users (&#8221; +</p>
<p>&#8221; uid INTEGER PRIMARY KEY AUTOINCREMENT, &#8221; +</p>
<p>&#8221; name TEXT, &#8221; +</p>
<p>&#8221; phonenumber TEXT)&#8221;;</p>
<p>6. Attach the connection and the query to the SQLStatement:</p>
<p>sql.sqlConnection = connection;</p>
<p>sql.text = sqlString;</p>
<p>7. Create event listeners for success and failure:</p>
<p>sql.addEventListener(SQLEvent.RESULT, onDBCreateTableResult);</p>
<p>sql.addEventListener(SQLErrorEvent.ERROR, onDBCreateTableError);</p>
<p>8. Execute! : sql.execute()</p>
<p>ﾠ</p>
<pre name="code" class="xml">

 <?xml version="1.0" encoding="utf-8"?>
 <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 width="438" height="251"
 creationComplete="onCreationComplete()">
 <mx:Script>
 <!--[CDATA[
 import mx.controls.Alert;
 import mx.events.DataGridEvent;
 import mx.collections.ArrayCollection;
 [Bindable] public var dp : ArrayCollection = new ArrayCollection();
 private var connection : SQLConnection;
 public var dbStatement : SQLStatement;
 public var dbFile : File;
 public var dbFileString : String = "exampledb.db";
 public function onCreationComplete():void
 {
 connection = new SQLConnection();
 dbFile = File.applicationStorageDirectory.resolvePath(dbFileString);
 // does the database exist?
 if( dbFile.exists )
 {
 // the database exists, so let's open it and read in the data
 connection.open(dbFile);
 loadData();
 } else {
 // the database does not exists, so let's create it
 createDB();
 }
 }
 public function createDB() : void
 {
 connection.addEventListener(SQLEvent.OPEN, onDBCreateResult);
 connection.addEventListener(SQLErrorEvent.ERROR, onDBError);
 // the following line creates the database if it does not exists, but we already know it doesn't
 connection.open(dbFile);
 }
 private function onDBCreateResult(event:SQLEvent):void
 {
 // we successfully created the database, so let's create our table
 createTable();
 }
 /*
 For this example we can use this error result handler for all our transactions
 */
 private function onDBError(event:SQLErrorEvent):void
 {
 Alert.show( event.error.name + " " + event.error.errorID + "\n" + event.error.details + "\n" + event.error.message);
 }
 public function createTable() : void
 {
 var sql : SQLStatement = new SQLStatement();
 sql.sqlConnection = connection;
 var sqlString : String = "CREATE TABLE Users (" +
 " uid INTEGER PRIMARY KEY AUTOINCREMENT, " +
 " name TEXT, " +
 " phonenumber TEXT)";
 sql.text = sqlString;
 sql.addEventListener(SQLEvent.RESULT, onDBCreateTableResult);
 sql.addEventListener(SQLErrorEvent.ERROR, onDBCreateTableError);
 sql.execute();
 sqlString = "INSERT INTO Users ( name, phonenumber) " +
 "VALUES ( 'Mac Martine', '555-1212')";
 sql.text = sqlString;
 //sql.addEventListener(SQLEvent.RESULT, onDBAddResult);
 sql.addEventListener(SQLErrorEvent.ERROR, onDBError);
 sql.execute();
 }
 private function onDBCreateTableResult(event:SQLEvent):void
 {
 trace('table created');
 loadData();
 }
 private function onDBCreateTableError(event:SQLErrorEvent):void
 {
 Alert.show( event.error.name + " " + event.error.errorID + "\n" + event.error.details + "\n" + event.error.message);
 trace( event.error.name + " " + event.error.errorID + "\n" + event.error.details + "\n" + event.error.message);
 }
 private function loadData():void
 {
 dbStatement = new SQLStatement();
 dbStatement.sqlConnection = connection;
 var sqlQuery:String = "select * from Users";
 dbStatement.text = sqlQuery;
 dbStatement.addEventListener(SQLEvent.RESULT, onRetrieveDataResult);
 dbStatement.addEventListener(SQLErrorEvent.ERROR, onDBError);
 dbStatement.execute();
 }
 private function onRetrieveDataResult(event:SQLEvent):void
 {
 var result : SQLResult = dbStatement.getResult();
 dp = new ArrayCollection();
 for each( var el : Object in result.data )
 {
 dp.addItem( { uid: el.uid, name: el.name, phonenumber: el.phonenumber } );
 }
 trace('cache retrieved');
 }
 public function add():void
 {
 var sql : SQLStatement = new SQLStatement();
 sql.sqlConnection = connection;
 dbStatement = new SQLStatement();
 dbStatement.sqlConnection = connection;
 var sqlString : String = "INSERT INTO Users ( name, phonenumber) " +
 "VALUES ( '(edit me)', '555-1212')";
 sql.text = sqlString;
 sql.addEventListener(SQLEvent.RESULT, onDBAddSuccess);
 sql.addEventListener(SQLErrorEvent.ERROR, onDBError);
 sql.execute();
 }
 public function onDBAddSuccess( event : SQLEvent ):void
 {
 var result : SQLResult = dbStatement.getResult();& lt;br /> var uid : Number = event.currentTarget.sqlConnection.lastInsertRowID;& lt;br /> loadData();
 }
 public function remove():void
 {
 var selectedItemUid : Number = dg.selectedItem.uid;& lt;br /> var selectedIndex : Number = dg.selectedIndex;<br /& gt; if( selectedIndex >= 0 )
 {<br /& gt; var sql : SQLStatement = new SQLStatement();<br /& gt; sql.sqlConnection = connection;<br /& gt; dbStatement = new SQLStatement();<br /& gt; dbStatement.sqlConnection = connection;<br /& gt; ﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠﾠvar sqlString : String = "DELETE FROM Users WHERE uid=" + selectedItemUid;& lt;br /> sql.text = sqlString;
 sql.addEventListener(SQLEvent.RESULT, onDBRemoveResult);
 sql.addEventListener(SQLErrorEvent.ERROR, onDBError);
 sql.execute();
 } else {
 Alert.show("You do not have a row selected to delete.");
 }
 }
 public function onDBRemoveResult( event : SQLEvent ):void
 {
 loadData();
 }
 public function update( event : DataGridEvent ):void
 {
 var sql : SQLStatement = new SQLStatement();
 sql.sqlConnection = connection;
 dbStatement = new SQLStatement();
 dbStatement.sqlConnection = connection;
 var sqlString : String = "UPDATE Users SET name = '" + event.itemRenderer.data.name + "' WHERE uid = " + event.itemRenderer.data.uid;
 sql.text = sqlString;
 //sql.addEventListener(SQLEvent.RESULT, onDBAddResult);
 sql.addEventListener(SQLErrorEvent.ERROR, onDBError);
 sql.execute();
 }
 ]]-->
 </mx:Script>
 <mx:DataGrid id="dg" dataProvider="{dp}" x="10" y="37" width="407" height="202" editable="true" itemFocusOut="update(event)" >
 <mx:columns>
 <mx:DataGridColumn headerText="Name" dataField="name" editable="true" />
 <mx:DataGridColumn headerText="Phone Number" dataField="phonenumber"/>
 </mx:columns>
 </mx:DataGrid>
 <mx:LinkButton x="300" y="10" label="Add" click="add()"/>
 <mx:LinkButton x="354" y="10" label="Remove" click="remove()"/>
 </mx:WindowedApplication>
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Data+storage+and+caching+with+SQLite+databases+and+Adobe+AIR+http%3A%2F%2Fbit.ly%2F4sVy4Q" title="Post to Twitter"><img class="nothumb" src="http://macmartine.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://macmartine.com/blog/2008/02/data_storage_and_caching_with_.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

