sqliteconnect #users, "test.db"
call execAndPrint "select * from users"
call execAndPrint "select count(*) from users"
#users disconnect()
end
sub execAndPrint query$
#users execute(query$)
while #users hasanswer()
result$ = #users nextrow$(",")
print result$
wend
end sub
SQLite is a popular database engine provided as a library and is supported for Windows, Mac and Linux. The source code is available and is in the public domain so it is completely free. We will support the parts of Run BASIC that integrate with SQLite, but as for the specific level of conformance to the SQL standard and other technical details, see http://www.sqlite.org/
The SQLITECONNECT #obj, "databasefile.db" statement connects to a database and sets the #obj variable to be a connection object. The connection object understands EXECUTE(), HASANSWER(), NEXTROW$() and DISCONNECT(). I'm sure there will be more commands.
Notice the NEXTROW$() method. It returns each query result row as a string, with each item delimited by the specified string ("," in the example but it could be CHR$(9) or something else). It is trivial then to use the WORD$() function to extract the information. We will certainly also add the ability to get items by name.