Cross Platform Sqlite

I am writing an application that needs to be run on iOS, Android, Windows Phone, WPF, Windows 8 Metro, Linux and Mac. I have about 95% of the code in the cross-platform area, but the user interface and some things obviously need to be encoded specifically for each platform.

Now we need to add very simple database support in the application, and I would really like to work with Sqlite from the cross-platform area in my code. Can this be done with any existing Sqlite shell, or do I need to create my own? Or should I use several Sqlite wrappers that have the same syntax and just reference different libraries from different csproj files (to the platform)?

I read this Q / A Is there a .NET / C # wrapper for SQLite? but after an hour of reading I’m still not sure how to make it work on all these platforms, so I thought that someone could think about these things in front of me.

+6
source share
2 answers

Some options for cross-platform development of .NET / C # with SQLite:

SQLitePCL.raw

Portable Class Library (PCL) for low-level (raw) access to SQLite

SQLitePCL.raw provides a very thin C # wrapper on the side of the SQLite C API. The API, open to SQLitePCL.raw, is hostile from the point of view of the application developer, but is intended to be used as a normal portable layer at which more friendly wrappers can be created.

License : Apache v2 License

Source code : https://github.com/ericsink/SQLitePCL.raw

Nuget : https://www.nuget.org/packages/SQLitePCLRaw.core

Platforms : Xamarin.Android, Xamarin.iOS, UWP, Windows Phone 8.1, .NET 4.5, .NET 4.0, .NET 3.5, Linux, MacOS, NetStandard 1.1, Windows Phone 8 (with restrictions), Windows Phone 8.1 Silverlight (with restrictions )


SQLitePCL.pretty

Pretty face on top of SQLitePCL.raw

This library wraps C, similar to SQLiteAPI provided by SQLitePCL.raw, with a friendly object-oriented C # API. SQLitePCL.pretty has extensive unit test coverage and supports many of the new features available in later versions of SQLite.

License : Apache v2 License

Source Code : https://github.com/bordoley/SQLitePCL.pretty

Nuget : https://www.nuget.org/packages/SQLitePCL.pretty

Platforms : same as SQLitePCL.raw


SQLite network

Simple, powerful cross-platform SQLite and ORM client for .NET.

SQLite-net was developed as a fast and convenient database layer. It is very easy to integrate with existing projects and works on all .NET platforms, with very simple methods for performing operations and CRUD requests safely (using parameters) and for obtaining the results of this request in a strongly typed way.

License : MIT License

Source code : https://github.com/praeclarum/sqlite-net

Nuget : https://www.nuget.org/packages/sqlite-net-pcl

Platforms : same as SQLitePCL.raw


Microsoft.Data.Sqlite

SQLite implementations of the System.Data.Common interfaces

This project is part of the ASP.NET kernel and is supported by Microsoft.

License : Apache v2 License

Source code : https://github.com/aspnet/Microsoft.Data.Sqlite

Nuget : https://www.nuget.org/packages/Microsoft.Data.SQLite

Platforms : .NET Framework, Mono, .NET Core (.NET Native, CoreCLR, Windows Universal), Xamarin (planned)

+2
source

I would recommend using the Mono version (http://www.mono-project.com/SQLite) of the SQLite shell. The shell itself is completely written in managed code, and you just need to provide the Sqlite library for the appropriate environment.

I had a C # project that ran on both Linux and Windows.

You MAY get away from using the official C # shell (http://system.data.sqlite.org/), but I'm not sure how it works with multiple platforms.

0
source

All Articles