Function Reference


_SQLite_Escape

Escapes a string or number for use as TEXT in SQLite statements

#include <SQLite.au3>
_SQLite_Escape ( $sString [, $iBuffSize = Default] )

Parameters

$sString string to escape
$iBuffSize [optional] Size of the escaped string to be returned (Default = complete escaped string)

Return Value

Success: an escaped string
Failure: an empty string and sets the @error flag to non-zero.
@error: 1 - Error Calling SQLite API 'sqlite3_mprintf'
2 - Error converting string to UTF-8
3 - Error reading escaped string

Remarks

The escaped string is already wrapped with single quotes.
For example "It's a fine day" is turned into "'It''s a fine day'".
For binary data use _SQLite_Encode().
For numeric value to be stored as such, use simple concatenation.

Related

_SQLite_Encode

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
Local $sTestString, $i, $aRow
For $i = 1 To 255
        $sTestString &= Chr($i)
Next
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a)")
_SQLite_Exec(-1, "INSERT INTO test VALUES (" & _SQLite_Escape($sTestString) & ")")
_SQLite_QuerySingleRow(-1, "SELECT a FROM test LIMIT 1", $aRow)
If $aRow[0] = $sTestString Then ConsoleWrite("! identical !" & @CRLF)
_SQLite_Shutdown()