filmov
tv
AutoIT Script Tutorial | Connecting SQLite Database with AutoIt Script Tutorial Part #1

Показать описание
In this tutorial session we will interact with sqlite database with autoit script. We are going to do following action items in this tutorial. Let's do it together-
Note: we can create 3 types of sqlite database as per our requirement.
1) Creating a :memory: database
2) Creating a temporary disk database
3) Creating a permanent disk database
C:\Program Files (x86)\AutoIt3\Extras\AutoUpdateIt
C:\Users\MacWin\AppData\Local\AutoIt v3\SQLite
here is the path : C:\Program Files (x86)\AutoIt3\Include
Step 3: Verify -- open autoit Script editor and run following lines of code.
Action Item 1 - Now we Create a memory database:
==========================================
_SQLite_Startup()
If @error Then
Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Creates a :memory: database and don't use its handle to refer to it
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!")
Exit -1
EndIf
_SQLite_Close()
----------------------------------------------------------------------------------------------------------------
Action Item 2 - Now we Create a temporary disk database:
========================================================
Local $hTmpDb = _SQLite_Open('') ; Creates a temporary disk database
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a temporary Database!")
Exit -1
EndIf
----------------------------------------------------------------------------------------------------------------
Action Item 3 - Now we Create a Permanent disk database:
========================================================
Local $sDbName = _TempFile()
Local $hDskDb = _SQLite_Open($sDbName) ; Open a permanent disk database
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't open or create a permanent Database!")
Exit -1
EndIf
----------------------------------------------------------------------------------------------------------------
; we can use the 3 database as needed by refering to their handle
; close the Dbs we created, in any order
_SQLite_Close($hTmpDb) ; temporary database are deleted automatically at Close
_SQLite_Close($hDskDb) ; DB is a regular file that could be reopened later
_SQLite_Close($hMemDb)
; we don't really need that DB
FileDelete($sDbName)
_SQLite_Shutdown()
If _SQLite_Startup() failed or was not executed, an AutoIt runtime error will be thrown, and the script will terminate!
AutoIt automatically closes any dlls it opened, but calling _SQLite_Shutdown() is still a good idea.
#AutoItConnectSQliteDatabase #coolithelp
Note: we can create 3 types of sqlite database as per our requirement.
1) Creating a :memory: database
2) Creating a temporary disk database
3) Creating a permanent disk database
C:\Program Files (x86)\AutoIt3\Extras\AutoUpdateIt
C:\Users\MacWin\AppData\Local\AutoIt v3\SQLite
here is the path : C:\Program Files (x86)\AutoIt3\Include
Step 3: Verify -- open autoit Script editor and run following lines of code.
Action Item 1 - Now we Create a memory database:
==========================================
_SQLite_Startup()
If @error Then
Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Creates a :memory: database and don't use its handle to refer to it
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!")
Exit -1
EndIf
_SQLite_Close()
----------------------------------------------------------------------------------------------------------------
Action Item 2 - Now we Create a temporary disk database:
========================================================
Local $hTmpDb = _SQLite_Open('') ; Creates a temporary disk database
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a temporary Database!")
Exit -1
EndIf
----------------------------------------------------------------------------------------------------------------
Action Item 3 - Now we Create a Permanent disk database:
========================================================
Local $sDbName = _TempFile()
Local $hDskDb = _SQLite_Open($sDbName) ; Open a permanent disk database
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't open or create a permanent Database!")
Exit -1
EndIf
----------------------------------------------------------------------------------------------------------------
; we can use the 3 database as needed by refering to their handle
; close the Dbs we created, in any order
_SQLite_Close($hTmpDb) ; temporary database are deleted automatically at Close
_SQLite_Close($hDskDb) ; DB is a regular file that could be reopened later
_SQLite_Close($hMemDb)
; we don't really need that DB
FileDelete($sDbName)
_SQLite_Shutdown()
If _SQLite_Startup() failed or was not executed, an AutoIt runtime error will be thrown, and the script will terminate!
AutoIt automatically closes any dlls it opened, but calling _SQLite_Shutdown() is still a good idea.
#AutoItConnectSQliteDatabase #coolithelp