3

I'm trying to open a database i downloaded using an xhrrequest and stored using the file system API with my google chrome browser (Version 30.0.1599.101 m) on windows 8 OS and hosted in IIS8.

I can find and open the file in my user folder, on the local file system. I opened the file with sqllitebrwser and the data seems to be present. However in the folder C:\Users\Ian\AppData\Local\Google\Chrome\User Data\Default\File System\001\p\00 it has the name "00000000". I think thats normal?

When i use the following code it says it can find the file on the file system.

function go() {
console.log('requesting file system...');
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.webkitStorageInfo.requestQuota(PERSISTENT, 10 * 1024 * 1024, function (grantedBytes) {
    window.requestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler);
}, function (e) {
    console.log('Error', e);
});;}

function onInitFs(fs) {
console.log('Opened file system: ' + fs.name);
fs.root.getFile('test.mbtiles', {create:false}, function (fileEntry) {
    var fullPath = fileEntry.fullPath;
    console.log('got file');
    var db = openDB();
}, errorHandler);}

When I try to execute a query.

function openDB(){
var shortName = 'test.mbtiles';
var version = '1.0';
var displayName = 'test.mbtiles';
var maxSize = 100000; // in bytes
var db  = openDatabase(shortName, version, displayName, maxSize);

   db.transaction(
    function (transaction) {
        transaction.executeSql('SELECT * FROM images', [], nullDataHandler, dbErrorHandler);
    }
);
return db;}

I get the error "Error was could not prepare statement (1 no such table: images) (Code 5) "

I've had this earlier and i'm pretty sure that the windows.openDatabase command could not locate the database and thus created a blank one.

I'm wondering why the window.opendatabase could not find the database. I think its looking in the wrong place, but how can i point the window.opendatabase to the right location, being the PERSISTENT storage of the browser. IVe been looking for a while now and all i can find is window.opendatabase examples using only the file name.

Thank you for any help.

  • Sadly I don't think this is directly possible. See: http://stackoverflow.com/questions/5481667/html5-load-web-sql-db-from-local-file – cgwyllie Nov 11 '13 at 18:11

1 Answers1

0

Create table with name "images" TIP: db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS images (id UNIQUE, name, size)'[],function(result){}, function(tx, error){alert(error.message));
});