This is a beta version for my updated SQLite library for v2.0+.
The main advantages of it are the ease of access of data in specialized objects.
Code: Select all
#Requires AutoHotkey v2.0+ ; prefer 64-Bit
#include <SQLite\SQLite>
db := SQLite(':memory:') ; this creates a temporary in-memory database
db.Exec('BEGIN TRANSACTION;')
db.Exec('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, column TEXT, value REAL)')
loop 20
db.Exec('INSERT INTO test VALUES(' A_Index ', "name' A_Index '", "value' A_Index '");')
db.Exec('COMMIT TRANSACTION;')
table := db.Exec('SELECT * FROM test')
msgbox table.count
for row in table.rows
names .= row.name '`n' ; "name" is the column which we setup on the example above
msgbox names
; or
for row in table.rows
{
for header, value in row
data .= header ' = ' value ', ' ; rows can be looped over as well
data .= '`n'
}
msgbox data
; you can access individual cells like this:
msgbox table[5, 'name'] ; returns 'name5'
; also you can get full rows like this:
row := table[5]
msgbox row.name
You can checkout the ReadMe file in the github repository for a quick intro and demonstration.
The code base has some basic unit testing and basic error handling as well.
The Object is split in 2 main parts: the SQLite object which is the public interface you would use in your code and the SQLite3 interface that is the one actually doing the actual work.
the SQLite object depends on the low-level SQLite3 interface (included in the code) that handles direct interaction with the DLL file so make sure you have them both in the file structure provided by the download file.
This library has a copy of the latest DLL releases so all in all it should be a self containing library that if you include in your projects you can use with very little modification.
Right now Im open to suggestions / improvement.