In my sqlite database there is a table called tiles. The columns in it are zoom_level (INTEGER), tile_row (INTEGER), tile_column (INTEGER) and tile_data (BLOB).
For anyone "in the know" these are industry standard raster ".mbtiles". They have PNG images stored as BLOB in the "tile_data" column. I can view these images in SQLIteBrowser application so I can confirm the db structure is correct and the images are there. I am using this test database from here https://www.google.com/url?sa=t&rct=j&q ... Hqj_QwldeC it is around 9.6 mb.
I have placed the MBTiles file beside the stack and the connection ID is an integer (ok). I can query other text from the database no problem.
Here is what I have tried...
Code: Select all
on test
local tQuery, tRecordSet, tImage, tResult, tID , tTypes -- some variables to aid in debugging
set the defaultFolder to specialFolderPath("resources") -- place the database file beside the stack
put revOpenDatabase("sqlite","countries-raster.mbtiles") into tID -- open the database
if tID is not a number then -- In my test tID is a valid integer meaning the connection was fine
answer error "Unable to open Database"
return empty
end if
-- build the test Query
put "select tile_data from tiles where ((tile_column = 0) and (zoom_level = 0) and (tile_row = 0))" into tQuery
put revQueryDatabase(tID,tQuery) into tRecordSet -- in my test the record set is a valid integer
put revDatabaseColumnTypes(tRecordSet) into tTypes -- should be "BLOB" but live code returns "STRING"
put revDatabaseColumnNamed(tRecordSet,"tile_data","tImage") into tResult -- some binary data (7 bytes) in here
-- put revDatabaseColumnNamed(tRecordSet,"tile_data","*btImage") into tResult -- tried prepending *b to the name of the variable, tImage is empty if I do this
-- basic tidy up
revCloseCursor tRecordSet
revCloseDatabase tID
-- this tells me the tImage variable is 7 bytes long but should be 13.48 kb according to the database
-- It also tells me the column has been identified as STRING
put "Data Length =" && the length of tImage && "Type(s) =" && tTypes
end test
I have tried going back back to version 9.5.1 stable but same results.