[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Binding arguments from SQL statements with LuaSqlite3
- From: Peter Odding <peter@...>
- Date: Fri, 25 Jun 2010 11:41:42 +0200
Using LuaSqlite3, I got the following error in the 'bind' method:
lua: cg.lua:13: bad argument #1 to 'bind' (number expected, got string)
Assuming we're talking about the same "LuaSqlite3" project, its homepage
seems to give an example of the usage of bind parameters which doesn't
look at all like your code. The page I'm talking about is:
http://www.nessie.de/mroth/lua-sqlite3/index.html
The code sample is:
require "sqlite3"
db = sqlite3.open("example-db.sqlite3")
db:exec[[ CREATE TABLE test (id, content) ]]
stmt = db:prepare[[ INSERT INTO test VALUES (:key, :value) ]]
stmt:bind{ key = 1, value = "Hello World" }:exec()
stmt:bind{ key = 2, value = "Hello Lua" }:exec()
stmt:bind{ key = 3, value = "Hello Sqlite3" }:exec()
for row in db:rows("SELECT * FROM test") do
print(row.id, row.content)
end
Note the stmt:bind{}:exec() calls, where bind() takes a table as its 1st
and only argument.
- Peter Odding