I have a set of HTML files and a SQLite database, which I would like to access from the browser, using the file:// scheme. Is it possible to access the database and create queries (and tables) using JavaScript?
If you want to get information from your database using javascript, you'll need to have javascript ask PHP to query the database through an AJAX call to a PHP script. In summary: Javascript can't connect to the database but it can ask PHP to do so.
SQLite is designed for situations where the data and application coexist on the same machine. SQLite can still be made to work in many remote database situations, but a client/server solution will usually work better in that scenario.
Actually the answer is yes. Here is an example how you can do this: http://html5doctor.com/introducing-web-sql-databases/
The bad thing is that it's with very limited support by the browsers.
More information here HTML5 IndexedDB, Web SQL Database and browser wars
PS: As @Christoph said Web SQL is no longer in active maintenance and the Web Applications Working Group does not intend to maintain it further so look here https://developer.mozilla.org/en-US/docs/IndexedDB.
EDIT
As @clentfort said, you can access SQLite database with client-side JavaScript by using SQL.js.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With