File: trg_sql3.lua

package info (click to toggle)
sc-im 0.8.5%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,972 kB
  • sloc: lisp: 32,533; ansic: 19,618; yacc: 1,489; xml: 518; sh: 410; makefile: 307; sed: 4
file content (34 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- trigger example of writing a cell content to sqlite3 database
-- use sqlite3 to create in /tmp/db.sql3
-- CREATE TABLE account ( date DATETIME, val REAL);
-- watch account table when defining trigger in scim
-- place this file in /usr/local/share/scim/lua
-- define trigger as follow : trigger a5 "mode=W type=LUA file=trg_sql3.lua function=trg"
-- when ever something writen to a5, it will be inserted into account table


function trg(c, r )


file=io.open("/tmp/log.txt", "a+")

local m_sql=require("luasql.sqlite3")
local m_env = m_sql.sqlite3()
local con = m_env:connect("/tmp/db.sql3")

val=sc.lgetnum(c,r)

file:write(string.format("%d %d value is %d",c,r,val))
file:flush()


local query="insert into  account values (datetime('now'),"..val..");"
print(val)
local cur1= con:execute(query)



end