The official ADO.NET wrapper for SQLite can be found at http://system.data.sqlite.org/.
This is an independent implementation of the core of ADO.NET: IDbConnection
, IDbCommand
, IDbDataReader
, IDbTransaction
(plus a few helpers) -- enough types to let you create and query SQLite databases from managed code, including support for libraries such as Dapper.
There are several problems with the official SQLite wrapper that prompted this replacement:
- Not Invented Here 😄
- Has performance problems, such as the
SQLiteFunction
static constructor that scans all loaded assemblies for usages ofSQLiteFunctionAttribute
. - Has complicated finalizers to work around incorrect use; this library instead just requires that
Dispose
be called on allIDisposable
objects. (These finalizers were in Robert Simpson's version; they may have been removed in later versions.) - Has interesting type conversion behavior.
- Introduces breaking changes.
- Doesn't support passing a VFS name to
sqlite3_open_v2
. - Builds platform-specific assemblies, instead of Any CPU ones.
- If we maintain our own fork to work around these changes, there are frequent conflicts when merging in new upstream versions.
There are also improvements we can make in a custom wrapper:
DbDataReader.ReadAsync(CancellationToken)
is overridden to support cancellation from another thread (viasqlite_progress_handler
).- Added
SQLiteConnection.StatementCompleted
to return the results ofsqlite3_profile
.
This library is generally compatible with the official System.Data.SQLite API, but a few changes were made where necessary:
- SQLiteConnectionStringBuilder does not support all the official connection string properties.
- SQLiteDataReader performs fewer implicit conversions.
- Not all SQL type aliases (
text
,int
,blob
, etc.) are supported.
This wrapper is managed-only; you still need a copy of the native SQLite library. A recent copy is provided in the lib
folder (for the unit tests).