Garry's Mod Wiki

sql.LastError

  string sql.LastError()

Description

Returns the last error from a SQLite query.

Returns

1 string
Last error from SQLite database.

Example

Reports all SQL errors into console automatically. Can help on debugging or testing.

sql.m_strError = nil -- This is required to invoke __newindex setmetatable(sql, { __newindex = function( table, k, v ) if k == "m_strError" and v then print("[SQL Error] " .. v ) end end } )
Output: After running sql.Query("SELECT") will print [SQL Error] incomplete input in the console.