How to load extensions into SQLite?

后端 未结 2 1188
感情败类
感情败类 2020-12-31 06:54

I need a standard deviation function in SQLite. I have found one here:

http://www.sqlite.org/contrib?orderby=date

but its part of an extension file to SQLit

2条回答
  •  遥遥无期
    2020-12-31 07:44

    SQLite extensions are libraries with dynamic linkage. You can find some examples here (This is a fossil repository, click on “login/fill captcha” to enable hyperlinks). See for example md5.c.

    • load_extension must be enabled in SQLite (pragma IIRC)
    • it requires as first argument the path of the library
    • The second argument is the name of the entry point function (in md5.c it is sqlite3_extension_init). Its prototype must be int(sqlite3*, char **, const sqlite3_api_routines *).
    • In SQL you can try SELECT load_extension('md5.so', 'sqlite3_extension_init'); or simply SELECT load_extension('md5.so');

    You can try to compile md5.c, and from the sqlite shell use .load md5.so

提交回复
热议问题