There is a version of SQLite compiled in Javascript:
http://www.syntensity.com/static/sqlite_wip.html
But as others said, it is not possible to do block access on files from
inside a Web browser's contained Javascript VM.
Nevertheless, theoretically you could load the full DB file in memory
[*], do your operations on it in memory and then write it as a whole
back to the disk, all on the client side.
lefteris.
[*] https://github.com/eligrey/FileSaver.js
On 14/09/12 16:05, Simon Slavin wrote:
On 13 Sep 2012, at 3:13pm, Jean-Denis Muys <jdm...@cmd-informatique.com> wrote:
I work on an application that uses an SQLite database as it's binary document
format (with a custom extension). Now we want to develop a Web App variation of
that application, that should be able to read and write those
documents/databases. Since the Web App is written in Javascript, I am now
looking for a Javascript implementation of the SQLite library.
This can't be done entirely in JavaScript, since JavaScript running in a web
browser has no way of getting at files on your hard disk. This is to prevent
the programmers of a web site spying on your computer's files.
I have used the C SQLite library in the past, so I know about using SQLite from
C. However, I am just starting with Javascript and Web Apps and I am quite a
newbie on that side (Other people on the team are experienced, but I have been
asked to work on the SQLite integration).
There are ways you can allow JavaScript to access data inside a file on a web
server. The standard way is to write a shim in PHP or some similar language.
The PHP code runs on the web server and uses PHP's SQLite3 library to access
databases. You ask it to execute a SQLite command, and it returns the results
in JSON (or some other) format. So for instance
https://myserver.com/databases/doSQLCommand.php?file=money.sqlite&command=SELECT
* FROM transactions WHERE id=123
might return a page of application/json type containing
{id: 123, trandate: "20030205", amount: 274.53}
Of course in real life you're more likely to pass the parameters using POST
than GET.
Your JavaScript code asks the shim for the data using an XMLHttpRequest and
uses JSON.parse() to turn the results into an array or an object.
There are, of course, many security concerns with such a setup, so most shim
programs check to see that they're being called only from their own server, by
a program they recognise, running on a computer they recognise. I sometimes
use a setup like this, though my shim returns the requested results as only a
small part of the stuff it returns, the rest being things like error messages
and last-insert-id and stuff like that.
Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users