0

I've started to explore using web databases (in this case the database in chrome) that you can run calls on using javascript. On document load, I begin by running the following function:

dbUtils = {
    db : null,
    initDatabase : function(){
        try
        {
            if(window.openDatabase)
            {
                this.db = openDatabase("testDB", "1.0", "Test Database", 2*1024*1024);
            }
        }
        catch(e)
        {
            alert("There was an error loading the database");
        }
    }
};

What I'm wondering is, is there a way to verify that the testDB exists OR if it already has any tables? Also is there a way I can list out all the table names that are within the database? This test is just to figure out if I should be initializing the user database with new data or if I should be using pre-existing data. I've been searching around for the solution but I cannot seem to be finding anything. I'm not sure if I'm putting in the wrong search terms, should I be searching under webDB? Or is there other terminology/names I should be using?

Thanks for your help!

NathanC
  • 71
  • 3
  • 1
    Although not answering your question the Web SQL Database spec has been dropped by the W3C (http://www.w3.org/TR/webdatabase/) in favour of IndexedDB. I'd recommend dropping this line of dev and starting with IndexedDB as it's in all major browsers (and IE10) - https://developer.mozilla.org/en/IndexedDB – Aaron Powell May 03 '12 at 03:43
  • This is definitely good to know! thanks! Although i briefly looked at it and saw that it is not compatible with safari or for native mobile browsers. The script I'm currently writing will need to run on mobile devices. I will be building a phonegap application. – NathanC May 03 '12 at 17:52

0 Answers0