SQLite data provider for SingleUserBlog

Please be aware that it may still have bugs. I have been using it now for about two weeks, making small refinements as I’ve found them.

To Install.

  1. Copy the “sub.db” file in the /Data directory.
  2. Ensure the “sub.db” file is writable and not read-only.
  3. Copy the "kowitz.SQLiteBlogDataProvider.dll" file into the /Bin directory.
  4. Copy the "System.Data.SQLite.dll" file to the /Bin directory.
  5. Change the config file so SUB now uses the SQLite provider: <DataAccessType> kowitz.SingleUserBlog.Services.DataReaderBlogDataProvider, kowitz.SQLiteBlogDataProvider </DataAccessType>

If you experience any problems when using the provider, just post comments here.


Get it here [Edit 10-Mar-06: Updated Link]

View Source Files Online

I've also uploaded my source files to view online, DataReaderBlogDataProvider.cs and SQLiteDataHandler.cs

.NET Internet Code Snippets SingleUserBlog
Posted by: Brendan Kowitz
Last revised: 21 Sep 2013 12:15PM


3/5/2006 4:32:42 PM
If you are migrating to this cool provider and you are currently running another provider - such as the default FileSystem provider - then you should make sure that you migrate your existing content prior to switching the providers in the web config file.

To do this, go to the Administration page and export your blog's content to BlogML. Then switch the providers in the config file. Then go to the Administration page and import your the content from the BlogML file.

3/5/2006 7:42:36 PM
One thing I forget to mention about the database schema I’ve chosen. It currently uses indexed, auto-incrementing ID columns. This means if you’re importing all your posts with GUIDs (or anything non-numeric), they will automatically be assigned a number to fit the schema, so your old post links may break. If there is enough interest for a schema with GUID ID columns then the source is not too hard to modify to support this. However, non-numeric IDs impact the effectiveness of an indexed column.
3/5/2006 10:29:45 PM
Hi Brendan, looks as though you have a typo in the UpdateCategory method of the SQLiteDataLayer. In that method you named the string "IaApproved" instead of "IsApproved".

3/5/2006 10:53:50 PM
Hi Brendan, I've just been going through some more of the code in the DataProvider and DataAccess classes and it seems to me that you would probably have issues with importing content from BlogML on a number of fronts. The Feedback that you import will still have a GUID as the ID of the post to which it is associated and because you change the post ID to an int they will no longer be attached.

If you'd like to do some tests on this I can send you my BlogML file so that you can import it to see what errors you get.

By the way I'm very much looking forward to using this SQLite provider :)

3/6/2006 12:30:32 AM
Thanks for that, good pick up on the sql typo. You’re correct about Feedback and Category IDs. I was simply trying to build the functionality around what databases do best…use indexes. I didn’t really have any initial plans for importing GUIDs and maintaining ID links (kind of defeating the point of BlogML, whoops). It’s also true to say that the auto-incrementing ID columns on the Feedback and Category tables will definitely cause a problem.

However, I am interested to see how SQLite performs with a decent sized blog. Not sure if the best thing in this case is to allow string ID columns, or work out how to convert to numeric IDs and keep the links. I’m open to any ideas or changes.
3/6/2006 7:44:27 AM
Does the database that you are using have GUID's? If so I wouldn't be too scared off by using them - especially for a blog which will typically only have thousands or, at the most, tens of thousands of rows. In fact you can actually "tune" GUID's on larger systems (tens of millions of rows) so that the perf. of using them is similar to using ints.

Refer this article for some comparison of metrics:

3/6/2006 1:42:12 PM

For the sake of convenience and interop, why use a GUID at all?

From my understanding, you don't get any benefit to using a GUID over an INT, other than 'it looks cool'. They are no more unique than a plain old INT coming from a sequence and in most cases (ie, not using SQL Server), you'll get worst performance since an index on a GUID field won't perform as well as an index on an INT.

3/6/2006 2:24:11 PM
>> For the sake of convenience and interop, why
>> use a GUID at all?

Because I was too lazy to write a function that would return monotonically increasing integers :-)
3/6/2006 2:40:43 PM
GUID's are nice to work with in the middle-tier; in other words, you don't have to run back to the database to get the next ID.
3/6/2006 6:08:21 PM

I can see why you used a GUID when you started writing SUBv1, you didn't have a database sequence to generate the numbers off.

What I'm thinking of now is a middle ground. If you install SUBv2 without a database (ala XML for storage), then it will continue to generate the GUIDs and everyone will be happy. If you either upgrade or install fresh and intend to use a database (whatever flavour really), then it'll automatically start use sequences for numbering.

How does that sit with you?

3/6/2006 6:32:08 PM
Changing the ID's of posts, categories, and feedback would mean that any current links to a post would break.

My main reason for using a *string* (as opposed to a GUID) for ID's was so that the blog could be totally interoperable with any data storage system and still have the capability to emulate whatever identifier that system used.

For example, if we wrote an Outlook plug-in for SUB what identifiers does Exchange use? And what about an Object Database?

I think that strings are still the best way to go for full compatability with other systems.

If we are talking about perf here I wouldn't get too anal about it. I mean what's a few thousand nanoseconds between friends - especially when most of the data can be cached for very long periods of time.
3/6/2006 7:03:50 PM
That’s a valid point. I think I'll modify the schema to allow for string IDs. This way anybody migrating to SUB with BlogML will be able to instantly make use of the SQLite provider. I really don't want to prevent anybody from using it.

That being said. My blog here will continue using the current INT ID schema mainly because I've been happy with it so far.

I can't wait to get some other blogs up and running in SQLite. I wanted to publish this code as a kind of 'beta idea' to see what everyone’s initial reactions would be. So thanks a lot for your input, keep it coming.

Shouldn't take too long to have another update out.

No new comments are allowed on this post.