admin管理员组文章数量:1417579
I have created an sqlite database file using sqlite browser.I have a file "sample.sqlite", now i wanted to know how to import this file in javascript and use the data in the sqlite file.I have been using 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) {}
By using this code i am not able to get the data from sqlite file.Please suggest me how to proceed.i have seen some sites where steps have been mentioned to create table,insert data by writing code in java script itself.But i don't know to do it that way i want to import the existing sqlite file.
I have created an sqlite database file using sqlite browser.I have a file "sample.sqlite", now i wanted to know how to import this file in javascript and use the data in the sqlite file.I have been using 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) {}
By using this code i am not able to get the data from sqlite file.Please suggest me how to proceed.i have seen some sites where steps have been mentioned to create table,insert data by writing code in java script itself.But i don't know to do it that way i want to import the existing sqlite file.
Share Improve this question asked Mar 25, 2013 at 11:12 user1537462user1537462 1973 silver badges9 bronze badges 2-
Be more specific than
i am not able to get the data
. – Tim Commented Mar 25, 2013 at 11:37 - I also am stuck on this concept of 'loading' an existing Sqlite database (say it's called employees.db) into the browser. Html pages are served from the webserver to the browser. Can I not also use Javascript to load a *.db file from the web server into the browser? Any examples I have seen start with an empty canvas...using Javascript (so it's all client-side work). They create an in-browser database, create tables and INSERT data....Is this the only way? Am I missing something ? I would like to pull this employees.db file from a webserver using Javascript. – barneymc Commented Aug 25, 2013 at 10:38
2 Answers
Reset to default 2Web apps are not allowed to access arbitrary files on the puter.
You could download some data from the same server where your JavaScript code es from, but it would be easier and faster to embed the SQL mands to create your database in your code.
(Use the .dump
mand of the sqlite3
mand-line tool to get these SQL mands.)
for Safari browser:
create dummy database in your HTML5.
after that copy database file name from mentioned location.
\Application Data\Apple Computer\Safari\Databases{your domain name}{database File name}
replace your database file name from newer one. and paste into the above mentioned location.
open your HTML5 page i hope it's work's good.
本文标签: javascriptHow to use an existing sqlite database in html5Stack Overflow
版权声明:本文标题:javascript - How to use an existing sqlite database in html5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745268850a2650766.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论