When I run the code:
row = db:first_row("SELECT MIN(rowid) from table")
local minID = row.rowid
row = db:first_row("SELECT MAX(rowid) from table")
local maxID = row.rowid
I get an error saying:
Runtime error: ...\db_test\main.lua:33: attempt to call method 'first_row' (a nil value)
stack traceback:
[C]: in function 'first_row'
...\main.lua:33: in main chunk
That exact same SQL query works in Python on the same database.
From the sqlite documentation
"ROWIDs and the INTEGER PRIMARY KEY
Every row of every SQLite table has a 64-bit signed integer key that uniquely identifies the row within its table. This integer is usually called the "rowid". The rowid value can be accessed using one of the special case-independent names "rowid", "oid", or "rowid" in place of a column name."
For anyone interested, the working code in my case is:
local minId
local maxId
for row in db:nrows("SELECT MIN(rowid) AS `rowmin` FROM " .. table) do
minId = row.rowmin
end
for row in db:nrows("SELECT MAX(rowid) AS `rowmax` FROM " .. table) do
maxId = row.rowmax
end