如何将扩展加载到SQLite中? [英] How to load extensions into SQLite?

查看:512
本文介绍了如何将扩展加载到SQLite中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要SQLite中的标准差函数。我在这里找到了一个:

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

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

,但这是SQLite扩展文件的一部分。我以前从未安装过其中一种,也不知道如何安装。我在 http://www.sqlite.org找到了这个现有功能 load_extension 。 /lang_corefunc.html ,但我不明白参数X和Y是什么。

but its part of an extension file to SQLite. I've never installed one of these before and I don't know how to. I found this existing function, load_extension, at http://www.sqlite.org/lang_corefunc.html, but I don't understand what the parameters X and Y are.

基本上,我需要有人逐步给我有关如何安装聚合扩展文件的指南。谁能做到这一点?

Basically, I need someone to give me a step by step guide on how to install the aggregate extension file. Can anyone do this?

推荐答案

SQLite扩展是具有动态链接的库。您可以在此处(这是一个化石存储库,请点击在登录/填写验证码上启用超链接)。参见例如 md5.c

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 必须在SQLite(pragma IIRC)中启用

  • 它需要作为第一个参数的库路径

  • 第二个参数是入口点函数的名称(在md5.c中,它是 sqlite3_extension_init )。它的原型必须为 int(sqlite3 *,char **,const sqlite3_api_routines *)

  • 在SQL中,您可以尝试 SELECT load_extension('md5.so','sqlite3_extension_init'); 或简单地 SELECT load_extension('md5.so');

  • 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');

您可以尝试编译 md5.c ,并从sqlite shell中使用 .load md5.so

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

这篇关于如何将扩展加载到SQLite中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆