Asked  7 Months ago    Answers:  5   Viewed   108 times

I'm just learning to use SQLite and I was curious if such is possible:

  1. Encryption of the database file?

  2. Password protect opening of the database?

PS. I know that there is this "SQLite Encryption Extension (SEE).", but according to the documentation, "The SEE is licensed software...." and "The cost of a perpetual source code license for SEE is US $2000."



SQLite has hooks built-in for encryption which are not used in the normal distribution, but here are a few implementations I know of:

  • SEE - The official implementation.
  • wxSQLite - A wxWidgets style C++ wrapper that also implements SQLite's encryption.
  • SQLCipher - Uses openSSL's libcrypto to implement.
  • SQLiteCrypt - Custom implementation, modified API.
  • botansqlite3 - botansqlite3 is an encryption codec for SQLite3 that can use any algorithms in Botan for encryption.
  • sqleet - another encryption implementation, using ChaCha20/Poly1305 primitives. Note that wxSQLite mentioned above can use this as a crypto provider.

The SEE and SQLiteCrypt require the purchase of a license.

Disclosure: I created botansqlite3.

Tuesday, June 1, 2021
answered 7 Months ago

If you want an Excel password all you need is something like this:

using Microsoft.Office.Interop.Excel

//create your spreadsheet here...

WorkbookObject.Password = password;

This requires Excel to be installed.

That's nothing to do with System.IO.Packaging of course, so you might need to restate your question...

Monday, July 5, 2021
answered 5 Months ago

One option which I did:

  • Store each of the schema and data population files as scripts in resources
  • Created a wrapper class that runs those scripts from resources
  • One of the resource files is a well known (by name) manifest, it has a list of the scripts to run in which order.
  • I have a poperties table in the database which stores what's the last script that ran.

That means:

  • On creation (first run) - it runs all scripts in succession
  • When app is updates - it runs all scripts that haven't run yet. The update carries more scripts in resources.

The scripts update schema and modify/munge existing customer data - of course without data loss.

BTW, I did this on iOS with the intent of sharing those sqlite scripts between android, winphone and other platforms. You just need the wrapper class on each platform that runs the sequences.

It also means I can run the scripts in order from the cmdline to create a db if needed ...


For example, in my sample app, Update1.sql is a file added as a resource. It has two sql batches in it. My wrapper opens the manifest file, get's the list of scripts to run, queries the database to see the last script ran, then creates an array of scripts to run. When it runs Update1.sql which is in the list, my wrapper class executes all the statements in that file thats embedded as a resource. For example, here's my Update1.sql

alter table messages add column user text;

create table log
    id integer primary key autoincrement, 
    information text    

Now, let's say the new table created needs some data in it. (in my case a log table doesn't). That scripts could contain a series of insert into statements right after the create table.

Executing multiple batches in a script requires the use of the tail argument in prepare. I have C/objective-c code if you would like to see it but I haven't written the android wrapper yet ...

Friday, July 30, 2021
Craig Ringer
answered 4 Months ago

This part:


is incorrect. It should be


When comparing primitive data types (like int, char, boolean) you can use ==, !=, etc.
When comparing objects (like String, Car, etc) you need to use the .equals() method.

See also this page.

Monday, August 2, 2021
answered 4 Months ago

WITHOUT ROWID was introduced in SQLite 3.8.2.

This means that it might or might not be supported on Android, depending on which Android version you're using.

Wednesday, November 24, 2021
Dale Zak
answered 6 Days ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :