sqlcipher/sqlcipher

Why does "sqlcipher" not have a LoadExtension function?

dudylan opened this issue · 11 comments

Why does "sqlcipher" not have a LoadExtension function?

How do I need to load external extensions

Provided that you have compiled SQLCipher with support for loadable extensions, you can use either of the methods described here:

https://www.sqlite.org/lang_corefunc.html#load_extension

Firstly, thank you for your reply
Secondly, sqlite does have a load_ Extension method.
And I'm using C # references https://github.com/praeclarum/sqlite-net When there is no load_ Extension method. I don't know what to do about it

Hi @dudylan

In sqlite-net, first you should call EnableLoadExtension, then you can use Execute to call the SELECT load_extension(...) that @sjlombardo linked to.

Hi @developernotes
image
As shown in the figure, Received the following error

“SQLiteException: not an error“

image
Similarly, I have also tried this one

Hi @dudylan,

Sorry, can you try calling ExecuteScalar instead?

@developernotes Unable to install

I submitted an example

Please take a look

Hi @dudylan,

If you modify your project to include the simple.dll and set 'Copy to output directory' as 'Copy always' for the file, the following modification to your demo will work properly:

var key = "aaa";
var options = new SQLiteConnectionString("xuanyou.db", true, key: key);
var _db = new SQLiteConnection(options);
_db.EnableLoadExtension(true);
var extensionPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "simple.dll");
_db.ExecuteScalar<int>($"SELECT load_extension('{extensionPath}');");
var value = _db.ExecuteScalar<string>("select simple_query('pinyin')");

Thank you for your answer. I have solved a big problem

Hi @dudylan,

Great, we're happy to hear that resolved the issue.