From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id 898BC21BD9 for ; Thu, 23 Jan 2025 20:36:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 09451485659 for ; Thu, 23 Jan 2025 20:35:14 +0100 (CET) Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=ntg.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntg.nl; h= content-transfer-encoding:content-type:content-type :list-unsubscribe:list-subscribe:list-post:list-owner:list-help :list-archive:archived-at:list-id:subject:subject:reply-to :precedence:in-reply-to:from:from:references:content-language :user-agent:mime-version:date:date:message-id:received:received :received:received:received:received:received; s=cgl; t= 1737660913; x=1740252914; bh=7+imKcG6pdMosWUkaksYXMoNh1GcSeTpfPC ZEcEP3ZA=; b=d5baNl39rT4gCi7LCgwqvmzffPrOCQfFpBYnnPUiwhHb8QcXfVq gH+hOHGXMYiedlJmWr55VyxW5TJKbp2q9u4yTuKce50/Fp0ju9G96WIoAjaslVlg fnFRvY9dzEG6csnLF0xXAZWSsSbrDvxQflxc5G3GMtESpomdTfmVSVXY= X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=xs4all.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RV5BDqfQM6CN for ; Thu, 23 Jan 2025 20:35:13 +0100 (CET) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 26A624858DD for ; Thu, 23 Jan 2025 20:33:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 57CF44853FB for ; Thu, 23 Jan 2025 20:32:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OJZo_GJD05q6 for ; Thu, 23 Jan 2025 20:32:38 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.121.94.167; helo=ewsoutbound.kpnmail.nl; envelope-from=j.hagen@xs4all.nl; receiver= Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id B06184853E3 for ; Thu, 23 Jan 2025 20:32:38 +0100 (CET) X-KPN-MessageId: 1268e073-d9c1-11ef-87cd-005056abbe64 Received: from smtp.kpnmail.nl (unknown [10.31.155.38]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 1268e073-d9c1-11ef-87cd-005056abbe64; Thu, 23 Jan 2025 20:34:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=9+4xNUf3yT1L8Wbf8lTxCWZdF3gug5kqERtVa9+e0wY=; b=uMN14V5CeKtKBGfUA5z7WO6KV0SEt4XhJL/zq6aQThd74GmeWW7okywYh73YcZCZwWcAOFFcETlHB 7sj5/8LHa33uFS10I4FYuRWYHRzR3rb8xqzojqibzwzA/lf6wtJ+8LqXRbT+s16gFClBATA7eAxFH7 bAw0O258J9fyyYncJGdu2o3ZF0Aa78pMXfsX2xW7GlveOFNesxNrehIGvr6LE1FiMrQQfKwouDgNHX Maw08cWFks97eD62xVlJxF0E0pNposabg8eKDNxK8TG7YNYHKu+rGCe+aDarE0pFhAgnCA6BOJBWeK QC8TYQJ0B/HvWj0wufkHoMuQTajZk5A== X-KPN-MID: 33|rEU0E8yHw4BNsuNPGNQGmTGOCn2IdT/oiuiP1t4BE4NQUVA7TOlQVh/hB3Vsj+R zvP5oEWsU3hoz4NcL7CuvITKxIyCAKO00T6VM43dlBu0= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|v1Q4x86hirISiFlzZo/ND2riaiIE+QrFPFr39OVrmhS1Es9L0oOFk/l1+FbQAd9 Hs2MjCuLYnVz+oiWeukAf7w== X-Originating-IP: 213.125.29.162 Received: from [10.100.1.105] (d57d1da2.static.ziggozakelijk.nl [213.125.29.162]) by smtp.xs4all.nl (Halon) with ESMTPSA id cdd0667a-d9c0-11ef-a30e-005056abf0db; Thu, 23 Jan 2025 20:32:38 +0100 (CET) Message-ID: <493c3dc3-1229-439a-90a3-550bd4fc8bc6@xs4all.nl> Date: Thu, 23 Jan 2025 20:32:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: nl To: ntg-context@ntg.nl References: <173765674875.3183020.18290724436829452253@cgl.ntg.nl> From: Hans Hagen In-Reply-To: <173765674875.3183020.18290724436829452253@cgl.ntg.nl> Message-ID-Hash: WB6RD7ZTLV32GKAKDOSAIHPRBZNLXPKT X-Message-ID-Hash: WB6RD7ZTLV32GKAKDOSAIHPRBZNLXPKT X-MailFrom: j.hagen@xs4all.nl X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: How to load external lua library List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit On 1/23/2025 7:25 PM, krulis.tomas@seznam.cz wrote: > Dear ConTeXt mailing list, > > I've been struggling with loading the sqlite external lua library. I tried the following: > > 1. Instaling the system package and running ConTeXt with the `--permitloadlib` option (I am running Manjaro, an arch-linux derivative: https://archlinux.org/packages/core/x86_64/sqlite/) > 2. Installing the luarocks package (https://luarocks.org/modules/dougcurrie/lsqlite3) for the 5.1, 5.3 and 5.4 lua versions. I also tried to symlink the files in $HOME/.luarocks/lib/lua/{version}/lsqlite3.so to the project directory > 3. I tried also setting the relevant lua paths with `eval $(luarocks path)`. > > The compilation always fails with an error that context can't locate the sqlite3 library. > > How can I load data from sqlite database during context compilation? As an MWE, I am adding the example in the documentation for the interaction with sqlite from the context garden (https://www.pragma-ade.nl/general/manuals/sql-mkiv.pdf): > > ```tex > \starttext > > \startluacode > require("util-sql") > utilities.sql.setmethod("sqlite") > require("util-sql-loggers") > > local loggers = utilities.sql.loggers > local presets = { > -- method = "sqlite", > database = "loggertest", > datatable = "loggers", > id = "loggers", > } > > os.remove("loggertest.db") -- start fresh > local db = loggers.createdb(presets) > loggers.save(db, { -- variant 1: data subtable > type = "error", > action = "process", > data = { filename = "test-1", message = "whatever a" } > } ) > > loggers.save(db, { -- variant 2: flat table > type = "warning", > action = "process", > filename = "test-2", > message = "whatever b" > } ) > > local result = loggers.collect(db, { > start = { > day = 1, > month = 1, > year = 2016, > }, > stop = { > day = 31, > month = 12, > year = 2116, > }, > limit = 1000000, > -- type = "error", > action = "process" > }) > > context.starttabulate { "||||||" } > > for i=1,#result do > local r = result[i] > context.NC() context(r.time) > context.NC() context(r.type) > context.NC() context(r.action) > > if r.data then > context.NC() context(r.data.filename) > context.NC() context(r.data.message) > else > context.NC() > context.NC() > end > > context.NC() context.NR() > end > > context.stoptabulate() > > -- local result = loggers.cleanup(db, { > -- before = { > -- day = 1, > -- month = 1, > -- year = 2117, > -- }, > -- }) > \stopluacode > > \stoptext > ``` > > I am sorry for the poor quality of the example, but I don't know how to add an attachment to a message in a mailing list. > > I have found a few references on the web and on this mailing list (https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/IDZBJQIXG3JIG5O5CNUNXUIPGR4UFTWE/), but I wasn't able to figure out what I could be doing wrong. I found a reference that the issue might be a version mismatch, so I tested multiple lua versions. > > My project is about using multiple data sources in multiple formats and creating reports from them. I know I will definitely need to load YAML as well (with the `lyaml` luarocks package I guess). There's always the alternative of trying to use other programs to get the data, but I was wondering if I could leverage ConTeXt to do that directly. > > Thank you for any guidance on this, and I hope this message is not too long ... On my machine I have: Directory of e:\tex-context\tex\texmf-win64\bin\lib\luametatex\sqlite 06/16/2017 10:24 AM 1,730,048 sqlite3.dll so, you should put sqlite3.so in a similar place in your texmf-linux tree just the regular lib, nothing needs to be compiled for lua \usewmodule[sql] should load the right thing then Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________