Is there a .NET/C# wrapper for SQLite?
I'd sort of like to use SQLite from within C#.Net, but I can't seem to find an appropriate library. Is there one? An official one? Are there other ways to use SQLite than with a wrapper?
System.Data.SQLite is an ADO.NET adapter for SQLite.
System.Data.SQLite was started by Robert Simpson. Robert still has commit privileges on this repository but is no longer an active contributor. Development and maintenance work is now mostly performed by the SQLite Development Team. The SQLite team is committed to supporting System.Data.SQLite long-term.
"System.Data.SQLite is the original SQLite database engine and a complete ADO.NET 2.0 provider all rolled into a single mixed mode assembly. It is a complete drop-in replacement for the original sqlite3.dll (you can even rename it to sqlite3.dll). Unlike normal mixed assemblies, it has no linker dependency on the .NET runtime so it can be distributed independently of .NET."
It even supports Mono.
Here are the ones I can find:
- other posters
There's also now this option: http://code.google.com/p/csharp-sqlite/ - a complete port of SQLite to C#.
The folks from sqlite.org have taken over the development of the ADO.NET provider:
From their homepage:
This is a fork of the popular ADO.NET 4.0 adaptor for SQLite known as System.Data.SQLite. The originator of System.Data.SQLite, Robert Simpson, is aware of this fork, has expressed his approval, and has commit privileges on the new Fossil repository. The SQLite development team intends to maintain System.Data.SQLite moving forward.
Historical versions, as well as the original support forums, may still be found at http://sqlite.phxsoftware.com, though there have been no updates to this version since April of 2010.
The complete list of features can be found at on their wiki. Highlights include
- ADO.NET 2.0 support
- Full Entity Framework support
- Full Mono support
- Visual Studio 2005/2008 Design-Time support
- Compact Framework, C/C++ support
Released DLLs can be downloaded directly from the site.
I'd definitely go with System.Data.SQLite (as previously mentioned: http://sqlite.phxsoftware.com/)
It is coherent with ADO.NET (System.Data.*), and is compiled into a single DLL. No sqlite3.dll - because the C code of SQLite is embedded within System.Data.SQLite.dll. A bit of managed C++ magic.
It is written in C# and is meant to be simply compiled in with your projects. It was first designed to work with MonoTouch on the iPhone, but has grown up to work on all the platforms (Mono for Android, .NET, Silverlight, WP7, WinRT, Azure, etc.).
It is available as a Nuget package, where it is the 2nd most popular SQLite package with over 60,000 downloads as of 2014.
sqlite-net was designed as a quick and convenient database layer. Its design follows from these goals:
- Very easy to integrate with existing projects and with MonoTouch projects.
- Thin wrapper over SQLite and should be fast and efficient. (The library should not be the performance bottleneck of your queries.)
- Very simple methods for executing CRUD operations and queries safely (using parameters) and for retrieving the results of those query in a strongly typed fashion.
- Works with your data model without forcing you to change your classes. (Contains a small reflection-driven ORM layer.)
- 0 dependencies aside from a compiled form of the sqlite2 library.
- Not an ADO.NET implementation. This is not a full SQLite driver. If you need that, use System.Data.SQLite.
Mono comes with a wrapper. https://github.com/mono/mono/tree/master/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0 gives code to wrap the actual SQLite dll ( http://www.sqlite.org/sqlite-shell-win32-x86-3071300.zip found on the download page http://www.sqlite.org/download.html/ ) in a .net friendly way. It works on Linux or Windows.
This seems the thinnest of all worlds, minimizing your dependence on third party libraries. If I had to do this project from scratch, this is the way I would do it.
Microsoft now provides Microsoft.Data.Sqlite as a first-party SQLite solution for .NET, which is provided as part of ASP.NET Core. The license is the Apache License, Version 2.0.
* Disclaimer: I have not actually tried using this myself yet, but there is some documentation provided on Microsoft Docs here for using it with .NET Core and UWP.
For those like me who don't need or don't want ADO.NET, those who need to run code closer to SQLite, but still compatible with netstandard (.net framework, .net core, etc.), I've built a 100% free open source project called SQLNado (for "Not ADO") available on github here:
It's available as a nuget here https://www.nuget.org/packages/SqlNado but also available as a single .cs file, so it's quite practical to use in any C# project type.
It supports all of SQLite features when using SQL commands, and also supports most of SQLite features through .NET:
- Automatic class-to-table mapping (Save, Delete, Load, LoadAll, LoadByPrimaryKey, LoadByForeignKey, etc.)
- Automatic synchronization of schema (tables, columns) between classes and existing table
- Designed for thread-safe operations
- Where and OrderBy LINQ/IQueryable .NET expressions are supported (work is still in progress in this area), also with collation support
- SQLite database schema (tables, columns, etc.) exposed to .NET
- SQLite custom functions can be written in .NET
- SQLite incremental BLOB I/O is exposed as a .NET Stream to avoid high memory consumption
- SQLite collation support, including the possibility to add custom collations using .NET code
- SQLite Full Text Search engine (FTS3) support, including the possibility to add custom FTS3 tokenizers using .NET code (like localized stop words for example). I don't believe any other .NET wrappers do that.
- Automatic support for Windows 'winsqlite3.dll' (only on recent Windows versions) to avoid shipping any binary dependency file. This works in Azure Web apps too!.
Version 1.2 of Monotouch includes support for System.Data. You can find more details here: http://monotouch.net/Documentation/System.Data
But basically it allows you to use the usual ADO .NET patterns with sqlite.
dotConnect for SQLite is an enhanced data provider for SQLite that builds on ADO.NET technology to present a complete solution for developing SQLite-based database applications. As a part of the Devart database application development framework, dotConnect for SQLite offers both high performance native connectivity to the SQLite database and a number of innovative development tools and technologies.
dotConnect for SQLite introduces new approaches for designing application architecture, boosts productivity, and leverages database application implementation.
I use the standard version,it works perfect :)
A barebones wrapper of the functions as provided by the sqlite library. Latest version supports functions provided sqlite library 3.7.10