简体   繁体   中英

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. Is there any way to connect to locally stored database through javascript. like

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

I use 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. 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? You can use SQL Lite with Cordova and bubble up from your Javascript to access the db. Check out: https://stackoverflow.com/a/26609184/1011603

Yes, it is possible to package your application and data file as web app by packaging appcache . Since browser manage data storage for database (indexeddb or websql), it is not possible to specify them by your file name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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