[Opensim-dev] CSharpSqlite as option in OpenSim.Data.Sqlite

Teravus Ovares teravus at gmail.com
Thu Sep 23 06:59:50 UTC 2010


Hey there

Since I have not had much response to my CSharpSqlite query in June, I
went ahead and committed the CSharpSqlite binary as well as my custom
ADO.NET wrapper for CSharpSqlite.   The source for them is
OpenSimLibs/trunk/managed.

Commit Hash: acd5bbdb71682131be386b7a5ce1904622b0ee70
ViewGit: http://opensimulator.org/viewgit/?a=commit&p=opensim&h=acd5bbdb71682131be386b7a5ce1904622b0ee70

For those of you who do not know what CSharpSqlite is, I suggest you
read: http://code.google.com/p/csharp-sqlite/
Summary:   It's an independent implementation of the SQLite library
written in C#.   There are no native libraries associated with it.
This has the advantage of having it work, out of the box in most
configurations.  (32bit/64bit/Win/Linux/Mac/more?).
Benchmarks: http://code.google.com/p/csharp-sqlite/wiki/Benchmarks

A couple of things that I've learned about it during the process of
getting it to work.

1. The SQLite database files that CSharpSqlite makes are not byte per
byte compatible.   Mono.Data.Sqlite and other native SQLite tools can
read databases created with CSharpSqlite but CSharpSqlite asserts on
databases created with Mono.Data.Sqlite

2. When running under CSharpSqlite, OpenSimulator will crash on the
first load.    Subsequent attempts to load OpenSimulator and it'll be
fine.

The ADO.NET wrapper that I wrote for CSharpSqlite is code compatible
with Mono.Data.Sqlite. That means that either can be used simply by
changing the using statement at the top of each of the SQLite*.cs
files  The same code that works for Mono.Data.Sqlite will also work on
CSharpSqlite because the inner namespaces are exactly the same.

To save on code maintenance, I implemented CSharpSqlite as the
compilation conditional CSharpSqlite in the OpenSim.Data.Sqlite
project.

#if CSharpSqlite
    using Community.CsharpSqlite.Sqlite;
#else
    using Mono.Data.Sqlite;
#endif

CSharpSqlite is easy to define in Microsoft Visual Studio but it's
slightly tougher for just plain Mono.

In Visual Studio, you right click the OpenSim.Data.Sqlite project in
the Solution Explorer.  Click Properties from the context menu.  Then
go to the Build Tab.  You'll see a box labeled 'Condition compilation
symbols' that's empty.   Simply enter CSharpSqlite into that box, save
the project and compile.

Apparently in Mono you use the -d:CSharpSqlite parameter when you
compile OpenSim.Data.Sqlite.     MonoDevelop may make this process
easier but I have no basis to work from.

Hopefully this helps people deal with issues relating to the use of SQLite

Regards

Teravus



More information about the Opensim-dev mailing list