Hallo Hans,
hallo Luigi,
Am Samstag, den 06.10.2018, 20:01 +0200 schrieb Jörg Hofmann:
> I've been trying to connect ConTeXt to sqlite for almost a week
> but I have repeatedly failed. Neither the
> "internal" variant according to the documentation, nor the attempt on
> luasql
> have worked. Above all, the Google request showed me that
> not alone with this problem - how reassuring. ;-)
>
> At the moment, concentrate I am accessing via swiglib and think my
> problem lies here (from my log file):
>
> sql> start loading method 'sqlite'
> swiglib> unknown: 'swiglib.sqlite.core'
> swiglib> unknown: 'swiglib.helpers.core'
>
> Obviously, the appropriate modules are not found, but where
> Can I get them and where do they belong? And maybe
> also someone a working code example for me.
> I'm working with Texlive 2017 on XUBUNTU 16.04.
>
> Best regards
> Jörg Hofmann
> _____________________________________________________________________
> ______________
> If your question is of interest to others as well, please add an
> entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt
> g-context
> webpage : http://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> _____________________________________________________________________
> ______________
Many thanks for your help. I have read both manuals but may not
understand it correctly. That's why I send my file and the log file.
Best regards
Jörg
open source > level 1, order 1, name '/usr/local/texlive/2017/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv'
system >
system > ConTeXt ver: 2017.05.15 21:48 MKIV beta fmt: 2017.11.1 int: english/english
system >
system > 'cont-new.mkiv' loaded
open source > level 2, order 2, name '/usr/local/texlive/2017/texmf-dist/tex/context/base/mkiv/cont-new.mkiv'
close source > level 2, order 2, name '/usr/local/texlive/2017/texmf-dist/tex/context/base/mkiv/cont-new.mkiv'
system > files > jobname 'lua-test', input './lua-test', result 'lua-test'
fonts > latin modern fonts are not preloaded
languages > language 'en' is active
open source > level 2, order 3, name '/home/jorg/Dokumente/Projekte/ConTeXt - Test/lua-test.tex'
fonts > preloading latin modern fonts (second stage)
fonts > 'fallback modern-designsize rm 12pt' is loaded
sql > start loading method 'sqlite'
swiglib > unknown: 'swiglib.sqlite.core'
swiglib > unknown: 'swiglib.helpers.core'
lua error > lua error on line 64 in file /home/jorg/Dokumente/Projekte/ConTeXt - Test/lua-test.tex:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: attempt to index local 'sqlite' (a boolean value)
stack traceback:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: in main chunk
[C]: in function 'requiem'
...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:180: in function <...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:165>
(...tail calls...)
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:114: in function '__index'
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:288: in function 'execute'
[ctxlua]:38: in main chunk
42
43 -- ***************************************************************************************************************
44 -- ** 1) intern mit swiglib
45 -- ***************************************************************************************************************
46
47 require("util-sql")
48 utilities.sql.setmethod("sqlite")
49
50 local presets = {
51 database = db,
52 >> }
53
54 local data, keys = utilities.sql.execute {
55 presets = presets,
56 template = abfrage,
57 }
58
59 context(data[titel])
60 context.crlf()
61 context(data[sachverhalt])
62 context.crlf()
?
lua error > lua error on line 64 in file /home/jorg/Dokumente/Projekte/ConTeXt - Test/lua-test.tex:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: attempt to index local 'sqlite' (a boolean value)
stack traceback:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: in main chunk
[C]: in function 'requiem'
...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:180: in function <...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:165>
(...tail calls...)
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:114: in function '__index'
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:288: in function 'execute'
[ctxlua]:38: in main chunk
42
43 -- ***************************************************************************************************************
44 -- ** 1) intern mit swiglib
45 -- ***************************************************************************************************************
46
47 require("util-sql")
48 utilities.sql.setmethod("sqlite")
49
50 local presets = {
51 database = db,
52 >> }
53
54 local data, keys = utilities.sql.execute {
55 presets = presets,
56 template = abfrage,
57 }
58
59 context(data[titel])
60 context.crlf()
61 context(data[sachverhalt])
62 context.crlf()
?
lua error > lua error on line 64 in file /home/jorg/Dokumente/Projekte/ConTeXt - Test/lua-test.tex:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: attempt to index local 'sqlite' (a boolean value)
stack traceback:
...texmf-dist/tex/context/base/mkiv/util-sql-imp-sqlite.lua:36: in main chunk
[C]: in function 'requiem'
...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:180: in function <...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:165>
(...tail calls...)
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:114: in function '__index'
...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:288: in function 'execute'
[ctxlua]:38: in main chunk
42
43 -- ***************************************************************************************************************
44 -- ** 1) intern mit swiglib
45 -- ***************************************************************************************************************
46
47 require("util-sql")
48 utilities.sql.setmethod("sqlite")
49
50 local presets = {
51 database = db,
52 >> }
53
54 local data, keys = utilities.sql.execute {
55 presets = presets,
56 template = abfrage,
57 }
58
59 context(data[titel])
60 context.crlf()
61 context(data[sachverhalt])
62 context.crlf()
End of file on the terminal!
\setuppapersize[A4]
\setuplayout[
%leftmargin=90mm,
backspace=10mm,
width=100mm,
%rightmargin=35mm
]
%
%
%\definelayout[ErsteSeiten][
% leftmargin=100mm,
% rightmargin=20mm
% ]
\starttext
\startluacode
-- local a=3
-- local b=5
-- local c = a + b
-- context("Hallo Josh")
-- context.crlf()
-- context("a= %s und b= %s. a + b = %s.",a, b, c)
-- ***************************************************************************************************************
-- ** Abfragen mit SQL
-- ***************************************************************************************************************
local abfrage = [[
SELECT
`titel`, `sachverhalt`, `auftraege`
FROM
`aufgabe`
WHERE `id` = '1';
]]
local db = "aufgaben.sqlite"
-- ***************************************************************************************************************
-- ** 1) intern mit swiglib
-- ***************************************************************************************************************
require("util-sql")
utilities.sql.setmethod("sqlite")
local presets = {
database = db,
}
local data, keys = utilities.sql.execute {
presets = presets,
template = abfrage,
}
context(data[titel])
context.crlf()
context(data[sachverhalt])
context.crlf()
context(data[auftraege])
\stopluacode
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________