How to use existing sqlite database in html5

I created a sqlite database file using sqlite browser.I have a sample.sqlite file, now I wanted to know how to import this file into javascript and use the data in sqlite file. I used this below mentioned script

var db; try { if (window.openDatabase) { db = openDatabase("sample.sqlite", "1.0", "HTML5 Database API example", 200000); if (!db) alert("Error Failed to open the database, check version"); } else alert("Error Not supported? Not gonna happen"); } catch(err) {} 

Using this code, I cannot get data from sqlite file. Please suggest me how to proceed. I saw some sites that mentioned the steps to create a table, insert data by writing code in a java script itself. But I do not know to do it this way, I want to import an existing sqlite file.

+6
source share
2 answers

Web applications are not allowed access to arbitrary files on the computer.

You can download some data from the same server where the JavaScript code is issued, but it would be easier and faster to implement SQL commands to create your database in your code. (Use the .dump command of the .dump command-line sqlite3 to get these SQL commands.)

+2
source

for Safari browser:

Create a dummy database in your HTML5.

after this database file name copies from the specified location.

\ Application Data \ Apple Computer \ Safari \ Databases {your domain name} {database name}

replace the database file name with a newer one. and paste in the above location.

open your HTML5 page, I hope it will work well.

0
source

All Articles