InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

SQLite Has Been Ported to .NET

Posted by Abel Avram on Aug 06, 2009

Sections
Operations & Infrastructure,
Architecture & Design,
Development
Topics
.NET ,
Data Access ,
Languages ,
Programming ,
Database ,
SQLite

Noah Hart has ported SQLite3 to C#. While the first port is slower than the original, the project opens the way for SQLite to be used in .NET managed projects without using P/Invoke or unsafe code.

The project, C#-SQLite, is hosted on Google Code and represents the complete porting of SQLite version 3.6.16 to C#, the code being licensed under the Creative Commons 3.0. C#-SQLite passes over 30,000 tests with only 9 still not working. The compiled binary exe is 528KB which is about the same as the original at 506KB. The performance is behind the original native C implementation, but Hart says that he made no attempt to optimize the code yet, and considers the performance as acceptable. All numbers represent Rows/second:

Test C#-SQLite SQLite
Insert 300K 1300K
Select 1500K 8450K
Update 60K 300K
Delete 250K 700K

Cory Nelson explains why an SQLite port is better than using other approaches: avoiding P/Invoke which “can be pretty slow and is not portable”. Another reason is that the C code uses “goto all over the place, which probably hampers optimization as opposed to exceptions.”

Many products, including Adobe AIR, contain and use SQLite. Probably the best use of C#-SQLite is for Silverlight projects, as Tim Anderson points out:

Others are hopeful for a local database manager for Microsoft Silverlight, writing to isolated storage.

… Silverlight does not allow platform invoke or code marked as unsafe; and while there are apparently only a few p/invoke calls I’m guessing there may be many unsafe sections since the original SQLite makes heavy use of pointers.

Although Silverlight is an implementation of the .NET Framework, it does not include the System.Data namespace. It does include System.Linq.

C#-SQLite is not an official version of SQLite, Hart not being affiliated with SQLite.org. Richard Hipp, the creator of SQLite and owner of its trademark, did not accept ”SQLite” to be included in the name of this port, but later agreed with C#-SQLite.

There are other managed databases, some of them being: Perst, db4o, Silverlight Database, System.Data.SQLite.

What is the difference between csharp-sqlite and sql# by Mark Nijhof Posted
Re: What is the difference between csharp-sqlite and sql# by Srikanth Remani Posted
Re: What is the difference between csharp-sqlite and sql# by Abel Avram Posted
How does this compare to System.Data.SQLite and Mono's implementation? by Bret Ferrier Posted
Re: How does this compare to System.Data.SQLite and Mono's implementation? by Abel Avram Posted
  1. Back to top

    What is the difference between csharp-sqlite and sql#

    by Mark Nijhof

    Hi,

    What is the difference between SQL# code.google.com/p/sqlsharp/ and csharp-sqlite code.google.com/p/csharp-sqlite/ all I can see is a diff name and license?

    -Mark

  2. Back to top

    Re: What is the difference between csharp-sqlite and sql#

    by Srikanth Remani

    Both seem to be similar or same, C#-SqlLite seems to be more complete than SqlSharp.

  3. Back to top

    How does this compare to System.Data.SQLite and Mono's implementation?

    by Bret Ferrier

    If you are wanting to use SQLite with a .Net project most people use System.Data.SQLite or the Mono version which I believe is Mono.Data.SQLite. What does this project offer that the two previously mentioned don't?

  4. Back to top

    Re: What is the difference between csharp-sqlite and sql#

    by Abel Avram

    They are the same, but I believe one of them is in the process of being closed. Initially there was another project on Google code, which is closed right now and not available, and Hart started another, SQLSharp. Then, R. Hipp agreed with using the name C#-SQLite, and Hart started yet another project for that.

  5. Back to top

    Re: How does this compare to System.Data.SQLite and Mono's implementation?

    by Abel Avram

    Previous SQLite projects for .NET represent SQLite wrappers/providers not pure managed code. They still take the P/Invoke penalty. This one is pure C# code, a line for line porting of SQLite/C. This can be used for Silverlight projects which have tighter security constraints.

Educational Content

Eventually Consistent HTTP with Statebox and Riak

Bob Ippolito explains how to solve concurrent update conflicts with Statebox, an open source library for automatic conflict resolution, running on top of Riak.

Java.next

Erik Onnen attempts to demonstrate that Java is still the best programming language for the JVM if simplified idioms are used along with proper tooling.

Evolution in Data Integration From EII to Big Data

Approaches to integrating data are changing with emergence of cloud computing.

Winning Hearts and Minds: How to Embed UX from Scratch in a Large Organization

Michele Ide-Smith presents the lessons learned in the process of introducing UX principles and techniques into a large organization through a series of small steps.

LMAX Disruptor: 100K TPS at Less than 1ms Latency

Dave Farley and Martin Thompson discuss solutions for doing low-latency high throughput transactions based on the Disruptor concurrency pattern.

Thoughts on Test Automation in Agile

Rajneesh Namta shares his thoughts, experiences, and some of the critical lessons learned while implementing software test automation on a recent Agile project.

Actor Interaction Patterns

Dale Schumacher presents several patterns of actor interaction that can be used in collaborative programs written in any language.

Scalaz: Functional Programming in Scala

Rúnar Bjarnason discusses Scalaz, a Scala library of pure data structures, type classes, highly generalized functions, and concurrency abstractions to perform functional programming in Scala.