lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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:

The code sample is:

  require "sqlite3"

  db ="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.content)

Note the stmt:bind{}:exec() calls, where bind() takes a table as its 1st and only argument.

 - Peter Odding