Skip to content

Conversation

@mnemnion
Copy link
Contributor

@mnemnion mnemnion commented Oct 4, 2018

for row in stmt:rows() do

stmt:rows() is an iterator function like pairs or ipairs, performing one :step() at a time until all rows are returned. It clearbinds and resets the prepared statement.

local conn = sql.open("")
conn:exec[[
CREATE TABLE t(id TEXT, num REAL);
INSERT INTO t VALUES('myid1', 200);
INSERT INTO t VALUES('myid2', 400);
]]
local stmt = conn:prepare("SELECT * FROM t")
for row in stmt:rows() do
  print(unpack(row))
end

--> myid1 200
--> myid2 400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant