SQLite is a self-contained, serverless, zero-configuration, transactional SQL database engine, widely deployed, used in the public domain, easily accessible, and cross-platform, and your updates will be transactional (see http://www.sqlite.org/ for more details).
You may use the SQLite database with your automation or AutoIt scripts. It implements most of SQL92. There are also many interface clients that can be used to administer SQLite.
You can get the SQLite3.dll
file from the following link by choosing sqlite-dll-win32-x86 from the Precompiled Binaries for Windows list:
You can add Msgbox(0,"Pause","Next step")
anywhere to stop program flow and follow every step:
#include <SQLite.au3> #include <SQLite.dll.au3> Global $dbName = "mydatabase.sqlite" ;Database name _SQLite_Startup() ;Loads SQLite3.dll _SQLite_Open($dbName) ;Opens/creates a disk SQLite database ;Syntax: CREATE TABLE [IF NOT EXISTS] TABLE_NAME (row data_type,row2 data_type...); ;[Optional]
_SQLite_Exec()
):SQLite_Exec(-1, "Create table tblTest (a,b int,c single not null);" & "Insert into tblTest values ('1',2,3);" & _ "Insert into tblTest values (Null,5,6);") ;Several Sql statements in a single line _SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Users (phone int UNIQUE,age int,name TEXT);") ;**Syntax: INSERT INTO TABLE_NAME[(row_name,row2_name)] VALUES(value1,value2) _SQLite_Exec(-1, "INSERT INTO Users VALUES (0011958745620,20,'Albert'),") _SQLite_Exec(-1, "INSERT INTO Users VALUES (0034654363456,20,'Emi'),") ;**Syntax: UPDATE TABLE_NAME SET row1=value,row2=value WHERE row=known_value _SQLite_Exec(-1, "UPDATE Users SET name='Jhon',age=23 WHERE phone=0011958745620;") ;**Delete Syntax: DELETE FROM TABLE_NAME WHERE row=known_value _SQLite_Exec(-1, "DELETE FROM Users WHERE phone=0011958745620;") ; Without _CallBackFunc function. No Row values _SQLite_Exec(-1, "DROP TABLE Users;") ; Remove the table ; Query Syntax and CallBackfunc for every row: ==================================== ;SELECT row1,row2 (note: use * to show all rows) FROM TABLE_NAME [WHERE row=value OR row=value AND row2=value2 LIMIT 10 (LIMIT: results) ORDER BY row ASC or DESC] _SQLite_Exec(-1, "SELECT * From Users", "_CallBackfunc") ; _CallBackfunc function will be called for each row, $s for every row & field. Func _CallBackfunc($aRow) Local $s For $s In $aRow ConsoleWrite($s & @TAB) Next ConsoleWrite(@CRLF) EndFunc ;==>_CallBackfunc
_SQLite_Close() _SQLite_Shutdown()
You use SQL Syntax for database management in a very easy and transparent way like MySQL. You get to know a small database file with rows (registers) and columns (fields) information.
The SQLite_Exec
parameters are as follows:
$hDB
: An open database, use -1 for using last opened database.$sSQL
: SQL statement(s) to be executed.$sCallback
: [optional] if specified, the callback function will be called for each row.You can also use more _SQLite
functions, such as the following:
_SQLite_GetTable2d
: Passes out a 2-dimensional array._SQLite_QuerySingleRow
: Reads out the first row of the result.You can read more about SQLite by visiting the following link:
http://www.autoitscript.com/forum/topic/17099-sqlite-semi-embedded-database-functionality-in-autoit/