Showing posts with label sqlite. Show all posts
Showing posts with label sqlite. Show all posts

Monday, 20 September 2010

WP7 Deploy Db as Content File

Some readers asked me about the possibility to use a database file deployed as Content with the project. Using the file directly from the content folder it is not possible as we do not have read/write access to content files. In fact if we use only the silverlight assemblies we don't have access to any content file. The solution is to use TitleContainer.Openstream from Microsoft.Xna.Framework (a reference should be added manually to your project) to read the content file and then save it to the IsolatedStorage. Once we have the file on IsolatedStorage we can use SQLiteClient to access it.

I've published an updated version of the SQLiteClient project adding a content file (test.db) and there is also ExecuteScalar inside the SQLiteCommand class.



Tuesday, 20 July 2010

WP7 SqliteClient Preview

WP7 developer devices are already out in the US and I still hope I will qualify for one here in Italy. I would really love to test one. Brandon PLEASE don't forget me :)
As my proposal was a better port of the Sqlite engine I did some optimizing on the engine and also implemented/adapted a SqliteClient that is easier to use than normal sqlite3 commands.
At the "engine" part I use the journal file persistent this way the engine doesn't delete and create the journal at each command. I've also eliminated SQLITE_DEBUG from conditional compilation symbols spares some temporary file access.
For the client at the beginning I've wanted to compile the System.Data and Sqlite class from Monotouch, but after looking a little bit at the source code I've realized that there are tons of things that doesn't make sense on WP7. I wanted to keep it simple and searching I've found the SqliteClient.cs written by Frank Krueger for Monotouch. I've adapted the class to run with our library and got a pretty nice result.
I've also improved the test project and now you are able to set how many rows will be inserted, select the inserted rows and see the elapsed times for insert/select commands. For the insert I've tested two methods: the first with prepare, step, finalize and the second one with sqlite3_exec (which should be the same) and the insert time are more or less the same.



Anyway it's only a preview as it was not intensively tested and because it can be improved. If some of you find ways to optimize the library please let me know and I will post it for everybody. Also let me know what you think.


Here you have the link to the source code

NAMASTE

Tuesday, 16 March 2010

Sqlite for WP 7 Series - Proof of concept

I was really excited a month ago when they announced Windows Phone 7 Series, but also disappointed because it looked unfinished. Yesterday when they released a CTP for Windows Phone development I was surprised that there is no local database support (in my opinion a step backward from Windows Mobile 6.5 and an essential feature for developing business applications).
What I've developed is a proof of concept application that implements Sqlite db engine inside Windows Phone 7 series. I've used csharp-sqlite developed by noah.hart and modified it to work with IsolatedStorage and WP7 Phone Tools CTP.
After some initial struggle with the library I wrote a simple test program:



Hope you will find it useful...
csharp-sqlite.wp.zip