Trouble inserting data into an sqlite3 database
#9
(11-22-2015, 08:50 AM)PureTryOut Wrote: I'm not sure how that would help me? I'm binding every value in my query, and changing it to bind_names did not work, I still get the same error.

Code:
function someFunc(playerName, someName, aData)
local sql = [=[
    INSERT INTO exports(plName, name, data)
    VALUES(:plName, :name, :data)
    ;
  ]=];

  -- Open DB
  local db = sqlite3.open('data.sqlite3');
  if not db then
    return false;
  end

  -- Execute statement
  local stmt = db:prepare(sql);

  -- Is it allright?
  if not stmt then
    db:close();
    return false;
  end

  -- Bind names
  stmt:bind_names({
    plName = playerName,
    name = someName,
    data = aData
  });

  -- Insert record
  local ret = stmt:step();

  if ret ~= sqlite3.OK and ret ~= sqlite3.DONE then
    stmt:finalize();
    db:close();
    return false;
  end

  -- Clean handler
  stmt:finalize();

  -- Close DB
  db:close();

return true;
end

Any questions?
Reply
Thanks given by:


Messages In This Thread
RE: Trouble inserting data into an sqlite3 database - by DrMasik - 11-22-2015, 09:31 AM



Users browsing this thread: 1 Guest(s)