简体   繁体   English

是否可以通过javascript(WebSQL或Indexeddb)在本地存储的数据库上执行数据库操作

[英]Is it possible to perform database operation on locally stored DB through javascript (WebSQL or Indexeddb)

i am developing offline web app for android platform and i want to use offline database for it. 我正在为Android平台开发离线Web应用程序,我想为此使用离线数据库。 Is there any way to connect to locally stored database through javascript. 有没有办法通过javascript连接到本地存储的数据库。 like 喜欢

    var db = opendatabase("file:///android_asset/myLocalDb.db");
    var Records = db.executeSQL("Select * form myTable");
    echo Records;

I use PouchDB . 我使用PouchDB It is a NoSQL type database backend, but has great cross platform support so you don't have to worry about the underlying storage mechanism across browsers. 它是NoSQL类型的数据库后端,但是具有强大的跨平台支持,因此您不必担心跨浏览器的基础存储机制。 If you have flexibility on the database type, it may be the easiest solution. 如果您对数据库类型具有灵活性,则它可能是最简单的解决方案。

Are you making a Cordova app, or in-browser hybrid offline but specifically targeting Android? 您是要离线制作Cordova应用还是浏览器内混合应用,但专门针对Android? You can use SQL Lite with Cordova and bubble up from your Javascript to access the db. 您可以将SQL Lite与Cordova一起使用,并从Javascript中冒泡以访问数据库。 Check out: https://stackoverflow.com/a/26609184/1011603 签出: https : //stackoverflow.com/a/26609184/1011603

Yes, it is possible to package your application and data file as web app by packaging appcache . 是的,可以通过打包appcache将您的应用程序和数据文件打包为Web应用程序。 Since browser manage data storage for database (indexeddb or websql), it is not possible to specify them by your file name. 由于浏览器管理数据库(indexeddb或websql)的数据存储,因此无法通过您的文件名指定它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM