views:

43

answers:

1

Hello:

I have recently seen articles on HTML5 and local Db creation and usage. I have also seen some examples of Javascript connection strings to existing Access Db backends. I am interested in finding a way to build a Db, pre-load it with records, and use a web app to connect and read the Db. For example, I have created many standalone applications with Tcl, in Windows, that read off of Sqlite Db files. Essentially, the application (.exe file) and Db file sit next to each other in a folder and function like any other Db application, except without the use of servers.

I would like to be able to do the same, but with a web app (.html) and Db file. Does anyone know if this is possible? As an example, I wanted to build a language application that runs in any browser, with pre-loaded words saved in the backend. So there would be two files, the web app, and the db file.

Any suggestions or links to resources would be really appreciated. The only thing close that I could come up with was connecting to Access via OLE through Javascript, however I need a Db that is multi-platform like Sqlite.

Thanks,

DFM

+1  A: 

Your web app, its local database, and the "priming" data will all have to start somewhere, so I'll assume this all gets rolling during a live connection to a web server. When this first hit comes in, you:

  1. Deliver the page and related code.
  2. In your JavaScript, test for the existence of the database.
    1. Exists? No priming necessary. Do nothing, or sync, etc.
    2. Doesn't exist? Build it and deliver initial data. If this is slow, you can give the user a friendly warning: "Setting up, please stand by." Depending on how you're pushing down all that data, you might even show a progress bar: "Initializing database: 10%"...
  3. There is no step 3.

Once setup is complete, this app could be entirely local -- no net connection required -- as long as you code it without the assumption of non-local resources.

References:

Ken Redler
Hi Ken, thanks for the suggestions. I saw the, "Getting Started with HTML5 Local Db" link earlier. The only problem is that it looks like the Db gets created when the html file is executed. However, it doesn't look like I can include an existing pre-loaded Db file with the html file.
I guess the question is this: Is there any substantive difference between delivering your starter database as described above, and somehow "including" a pre-existing database? In both cases the data have to move from the source (you, your servers?) to the browser environment. Making it happen on demand would seem to give you more flexibility. I guess one unconventional idea would be to include another HTML document loaded with a huge json structure of all the data...then have the startuup process somehow reference this companion file during the initial db build stage.
Ken Redler
Hi Ken, your suggestion seems to be the best answer, so I clicked the check and added a point. It seems like there isn't code or a set of code currently available to build an application that runs through a browser and connects to an existing local database. My vision was to allow end-users to paste the HTML/JS application and Db file to there desktop (cross-platform based on browser type), and run it from there with the ultimate goal of not having to install anything. Thanks