SQLite is something I have wanted in AppGameKit for some time and ideally I would need this on android to but a Windows only solution is still very useful to me so I thought I would crack on and make it happen and I'm sure some of you will find it useful
Consider this a WIP as there's still a few additions I would like to add
Example:
#import_plugin SQLite as sql
// temp array for results
results as string[]
// open a database, if the db does not exist it will be created.
db = sql.Open("media\mydb.sqlite")
if db
// create a table and insert some data
sql.Update(db, "DROP TABLE IF EXISTS food")
sql.Update(db, "CREATE TABLE food (name CHAR(50), weight INT, price REAL)")
sql.Update(db, "INSERT INTO food (name, weight, price) VALUES ('apple', '10', '12.3')")
sql.Update(db, "INSERT INTO food (name, weight, price) VALUES ('pear', '5', '23.5')")
sql.Update(db, "INSERT INTO food (name, weight, price) VALUES ('banana', '20', '33.2')")
// Example using a custom function with 'Bind' functions
Insert(db, "peach", 15, 22.5)
Insert(db, "plumb", 17, 27.3)
Insert(db, "grape", 7, 15.6)
// get the last insert row id
last_id=sql.LastInsertID(db)
// perform a select query
if sql.Query(db, "SELECT * FROM food")
// loop the results and add to the temp array
while sql.NextRow(db) <> 0
results.insert(sql.GetString(db, 0)+" - "+str(sql.GetInteger(db, 1))+" - "+str(sql.GetFloat(db, 2),1))
endwhile
// finish this query
sql.FinishQuery(db)
endif
// close the database
sql.Close(db)
endif
do
// display data
print(last_id)
for i=0 to results.length
print(results[i])
next
//Print( ScreenFPS() )
Sync()
loop
Function Insert(database, str_val as string, int_val, float_val as float)
sql.BindString(database, 0, str_val)
sql.BindInteger(database, 1, int_val)
sql.BindFloat(database, 2, float_val)
sql.Update(database, "INSERT INTO food (name, weight, price) VALUES (?, ?, ?)")
EndFunction