admin管理员组文章数量:1334663
I have recently seen articles on HTML5 and local Db creation and usage. I have also seen some examples of Javascript connection strings to existing Access Db backends. I am interested in finding a way to build a Db, pre-load it with records, and use a web app to connect and read the Db. For example, I have created many standalone applications with Tcl, in Windows, that read off of Sqlite Db files. Essentially, the application (.exe file) and Db file sit next to each other in a folder and function like any other Db application, except without the use of servers.
I would like to be able to do the same, but with a web app (.html) and Db file. Does anyone know if this is possible? As an example, I wanted to build a language application that runs in any browser, with pre-loaded words saved in the backend. So there would be two files, the web app, and the db file.
Any suggestions or links to resources would be really appreciated. The only thing close that I could e up with was connecting to Access via OLE through Javascript, however I need a Db that is multi-platform like Sqlite.
Thanks,
DFM
I have recently seen articles on HTML5 and local Db creation and usage. I have also seen some examples of Javascript connection strings to existing Access Db backends. I am interested in finding a way to build a Db, pre-load it with records, and use a web app to connect and read the Db. For example, I have created many standalone applications with Tcl, in Windows, that read off of Sqlite Db files. Essentially, the application (.exe file) and Db file sit next to each other in a folder and function like any other Db application, except without the use of servers.
I would like to be able to do the same, but with a web app (.html) and Db file. Does anyone know if this is possible? As an example, I wanted to build a language application that runs in any browser, with pre-loaded words saved in the backend. So there would be two files, the web app, and the db file.
Any suggestions or links to resources would be really appreciated. The only thing close that I could e up with was connecting to Access via OLE through Javascript, however I need a Db that is multi-platform like Sqlite.
Thanks,
DFM
Share Improve this question edited Jul 11, 2010 at 4:58 mechanical_meat 170k25 gold badges236 silver badges227 bronze badges asked Jul 11, 2010 at 4:51 user175328user175328 3233 gold badges10 silver badges23 bronze badges 3- Do you want it all to be local? It's a bit confusing, since you specify web app. That kinda assumes that it's a client/server thing. – George Marian Commented Jul 11, 2010 at 5:00
- 1 Just build a normal app. There are better UI toolkits than HTML for GUIs IMVHO ;) – Aiden Bell Commented Jul 11, 2010 at 5:07
- Hi - thanks for your ments. Yes; I would want it all to be local. Sorry for the confusion. I wanted to pre-load a Db file with records, and write a html/JS application that would connect to the pre-loaded Db file. I do not want to use any server-side coding, so it would all be client-side (i.e. html, js, sql-connetion strings), and rendered through a web browser. – user175328 Commented Jul 11, 2010 at 16:46
2 Answers
Reset to default 3Your web app, its local database, and the "priming" data will all have to start somewhere, so I'll assume this all gets rolling during a live connection to a web server. When this first hit es in, you:
- Deliver the page and related code.
- In your JavaScript, test for the existence of the database.
- Exists? No priming necessary. Do nothing, or sync, etc.
- Doesn't exist? Build it and deliver initial data. If this is slow, you can give the user a friendly warning: "Setting up, please stand by." Depending on how you're pushing down all that data, you might even show a progress bar: "Initializing database: 10%"...
- There is no step 3.
Once setup is plete, this app could be entirely local -- no net connection required -- as long as you code it without the assumption of non-local resources.
References:
- Getting Started with HTML5 Local Databases
- Offline Web Applications in HTML5
You can access an already created sqlite db file through javascript. Look at the "Location of Database File" area of this link http://code.google./apis/gears/api_database.html
I know this is for Google Gears, but Gears uses SQLite and the location still applies without Gears and only using a sqlite db file.
For example, I used a firefox add-on 'SQLite Manager' to create a sqlite db file on my local machine. I then copied that file to C:\Users\\AppData\Local\Google\Chrome\User Data\Default\databases\file__0
I was able to access the file using JavaScript in Google Chrome:
var db = null;
try {
if (window.openDatabase) {
db = openDatabase("mydbfile.sqlite", "1.0", "HTML5 Database API example", 200000);
....
You have to be careful with the file name in Chrome as it automatically names each sqlite db by an id number. For example, I had to rename my sqlite db file name to 14 to get it to read from JavaScript in the browser. Once I did this, it worked like a champ and I was able to access all tables, data, etc.
本文标签: sqlitePreloaded Local Database Backend for Javascript (Possible)Stack Overflow
版权声明:本文标题:sqlite - Pre-loaded Local Database Backend for Javascript (Possible?) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742378489a2463640.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论