Something like this (didn't test, may need tweaking and definitely needs better error handling):
-- walls is an array-table: {{x1, y1, z1}, {x2, y2, z2}, ... } db:exec("BEGIN TRANSACTION") -- Postpone all DB changes into one big step, to save on disk I/O local stmt = db:prepare("INSERT INTO GardenWalls (x, y, z) VALUES (?, ?, ?)") for wall in ipairs(walls) do stmt:bind_values(unpack(wall)) -- insert "wall" values into the statement stmt: step() -- execute the statement (once); the space before S should not be there (forum limit) stmt:reset() -- reset the statement so that the next "wall" values can be inserted end stmt: finalize() DB:exec("COMMIT") -- Now put everything queued so far into the DB file