I assume the table has to be in some system folder where it can be reached, but i don't know which...
It's kind of stupid the sqlite.so has to be in the lib folder and Linux does not search in the program executable directory itself
Help, anyone :roll:
Code: Select all
#SQLITE_OK =0 ; Successful Result
Procedure.l SQLite_Get_Table(DB_Handle.l, SQLString.s, * Rows, * Cols)
Shared Result.l
Shared LResultsPtr.l
Shared LRows.l
Shared LCols.l
Result = CallFunction(0, "sqlite_get_table", DB_Handle, SQLString, @LResultsPtr, @LRows, @LCols, 0)
If Result = #SQLITE_OK
; return number of rows/columns
PokeL(*Rows, LRows)
PokeL(*Cols, LCols)
; redimension results array (clears data)
Dim DBData.s(LRows, LCols - 1)
; copy data into array
Address.l = LResultsPtr
AddrInc.l = LCols * 4
For Row.l = 0 To LRows
For Col.l = 0 To LCols - 1
DBData(Row, Col) = PeekS(PeekL(Address + Col * 4))
Next
Address + AddrInc
Next
; free table memory
CallFunction(0, "sqlite_free_table", LResultsPtr)
EndIf
ProcedureReturn Result
EndProcedure
errormsg.s=""
If OpenLibrary(0,"sqlite.so")
db=CallFunction(0,"sqlite_open","test.db",0,errormsg)
If db
SQL.s = "SELECT id, url, site, category FROM bookmarks WHERE category LIKE 'delp%'"
Result = SQLite_Get_Table(db, SQL, @Rows, @Cols)
If Result = #SQLITE_OK
; get the results
; display number of rows/columns
a$=""
a$+ "Rows = " + Str(Rows)+Chr(10)
a$+ "Columns = " + Str(Cols)+Chr(10)+Chr(10)
; display column headers
For Col.l = 0 To Cols - 1
a$+ DBData(0, Col)+Chr(10)
Next
; display returned rows
For Row.l = 1 To Rows
a$+ "--------------" +Chr(10)
For Col = 0 To Cols - 1
a$+ DBData(Row, Col)+Chr(10)
Next
Next
CallFunction(0,"sqlite_close",db)
MessageRequester("Result",a$)
a$=""
Else
MessageRequester("Error","Unable to make query"+Chr(10)+errormsg)
EndIf
Else
MessageRequester("Error","Unable to open database"+Chr(10)+errormsg)
EndIf
Else
MessageRequester("Error","Unable to open library")
EndIf

