praeclarum / sqlite-net

Simple, powerful, cross-platform SQLite client and ORM for .NET
MIT License
4.03k stars 1.42k forks source link

How to use sqlite-net-pcl with SQLite Encryption Extension (SEE) #879

Open bouwe77 opened 5 years ago

bouwe77 commented 5 years ago

We are considering using the official implementation of SQLite Encryption Extension (SEE): https://www.sqlite.org/see/doc/release/www/index.wiki.

At the moment we are using sqlite-net-pcl and would like to keep using that.

So my question is how to do this?

If I understand the SEE documentation correctly you have to build the sqlite3.dll yourself and that's all. But can we use that DLL instead of the one that is used when using sqlite-net-pcl without encryption?

I was not able to find documentation on this.

Thanks, Bouwe

ericsink commented 5 years ago

I'll assume for the moment that your project is okay with .NET Standard 2.0, which means you can use SQLitePCLRaw 2.x. If you need to stay with SQLitePCLRaw 1.x, the instructions are different, and more difficult.

At a high level (with certain details omitted), the steps look like this:

  1. Instead of sqlite-net-pcl, add a reference to sqlite-net-base 1.7 beta (which is another packaging of the same code). In a portable library project, this is the only thing you need to reference.
  2. In your app project, add your custom-built sqlite3.dll to the build such that it shows up in your app output directory. Details on this depend on what platform and tooling you are using.
  3. In your app project, add a reference to one of the SQLitePCLRaw.provider.* packages. The right one to choose depends on platform and tooling. SQLitePCLRaw.provider.dynamic.cdecl is a good guess.
  4. In your app project, somewhere near startup, add code to initialize the SQLitePCLRaw provider. Details of this depend on which provider you chose.

In other words, using a custom sqlite native library requires you to do some of the same stuff that the SQLitePCLRaw "bundles" would normally do for you. If you need to do this in a cross-platform manner, things get quite a bit more complicated.

If you give more specifics, I can talk you through the details.

bouwe77 commented 4 years ago

Thank you for your detailed answer! 👍 :)

We are buidling a WPF application with .NET Framework 4.7.2 which will be installed on Windows 10 desktops.

Does this change anything on the steps you gave?