-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
I have 2 pieces of code, the one like the example of the README.md and the other the code that is on #113 . I have these questions:
- How do I define the tables in order to make them compatible with the
sqlite_tbl? Initially I thought that when I connect the DB and define the tables these tables would be created (like an ORM) but it seems like doesn't work like that. So, when I declare a"luatable"type in a column what type should I declare in the SQL definition?text,varcharor something else?
I have this code by the way
local sqlite = require 'sqlite'
local db = sqlite {
uri = "db.sqlite",
projects = {
objectives = "luatable",
title = { "text", unique = true, primary = true},
created = { "timestamp", default = sqlite.lib.strftime("%s", "now") },
done = "boolean"
},
todos = {
id = true,
title = "text",
project = { "text", reference = "projects.title", on_delete = "cascade" }
},
}
if db:exists("projects") == false then
db:execute("create table projects")
endand it gives me the following error:
luajit: /usr/local/share/lua/5.1/sqlite/stmt.lua:24: Invalid connection passed to sqlstmt:parse
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/sqlite/stmt.lua:24: in function 'parse'
/usr/local/share/lua/5.1/sqlite/db.lua:249: in function 'eval'
/usr/local/share/lua/5.1/sqlite/db.lua:324: in function 'exists'
sq.lua:18: in main chunk
[C]: at 0x56455f2641d0
Metadata
Metadata
Assignees
Labels
No labels