Question

I have done some googling but maybe I am not using the right terms ("sqlite reference web app"). I would like a example app which has a html page and writes submitted data to a sqlite database.

I know there are lots of examples out there, but they seem to require a lot of superstructure.

I am hoping - and maybe looking for something that does not exist - that there is a way to submit data to a SQLite database in a single web application folder structure.

Example:

/pub/docs/helloworld <-- in file structure, not deployed on web server

  1. index.html - basic form with data section and form/submit button
  2. foo.js - reads/writes data to hello.db
  3. hello.db - sqlite database

Use case:

  1. On load in a browser, index.html uses foo.js pulls a set of data from a view in hello.db and displays to the user.
  2. User enters data and clicks submit.
  3. index.html + foo.js update/create data in hello.db.

Do I need to install a full-blown app server for this, or can I do it with foo.js (+ a JS lib if required) only?

No, this is not a homework assignment, just trying to get a workbench for a project which I'd like to deploy on a shared internal filesystem instead of an application server.

I do know about TiddlyWiki and if it were a little more interactive querying-type structure where a user could search for a set of tags I might be able to use it, but I'm also interested in learning more about SQLite.

Any advice appreciated. Thanks.

Was it helpful?

Solution

Within the context of a web browser, you will be limited by the possibilities of that browser. You cannot access an SQLite database in an arbitrary file from browser-based Javascript.

The new HTML 5 standard does have a localStorage mechanism, which stores key-value pairs in the browser itself. Mozilla browsers also support a (proprietary) WebDatabase technology, which allows you to access an SQLite database through the browser. But even then, it’s the browser who determines where that database will be stored.

For a single-page, client-only app, I suggest you read http://www.diveintohtml5.org; it’s very informative and will bring you up to speed as to the new HTML technologies that can be used. If it’s too complex for you, then I suggest starting with a regular HTML tutorial first.

If you really want to be able to access a database, then you’re going to need some kind of server-side technology. For experimentation purposes, you could try node.js (or PHP/Apache, or one of a host of ‘regular’ web application frameworks).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top