HTML5 database storage (SQL lite) - few questions

前端 未结 5 826
一生所求
一生所求 2020-11-30 01:51

Hy there,

I can\'t find enough beginner resources on the web about HTML5 database storage usage examples (CRUD)

I\'m opening(creating) my DB like this:

相关标签:
5条回答
  • 2020-11-30 02:22

    The spec you're looking for is Web SQL Database. A quick reading suggests:

    1. There is no limit, although once your databases increase beyond a certain size (5MB seems to be the default), the browser will prompt the user to allow for more space.
    2. There is no way, in the current spec, to delete databases.
    3. The executeSql() function takes an optional error callback argument.

    HTML5 Doctor also has a good introduction.

    Going forward, though, I'd recommend looking at Indexed DB. Web SQL has essentially been abandoned since there is no standard for SQL / SQLite. Even Microsoft has endorsed Indexed DB. See Consensus emerges for key Web app standard.

    0 讨论(0)
  • 2020-11-30 02:27

    Using PersistenceJS there is a persistence.reset API which will wipe the database clean. PersistenceJS Site

    For developing / testing purposes, you can view content and delete webSQL, IndexedDB, cookies, etc by searching for your domain name at this URL in Chrome:

    chrome://settings/cookies
    

    There, you can delete all the storage for a domain or just certain local storage entities. Yes, the URL implies just 'cookies', but the interface at this URL includes all types of offline storage.

    It would be great I think if the Chrome developer tools interface had the ability to right-click and delete a data storage entity in the Resources tab along with inspecting the content. But for now, all I know of is the settings/cookies URL.

    0 讨论(0)
  • 2020-11-30 02:36

    It is supported on iOS safari,chrome and some latest version of opera....it's not yet adopted by IE and Firefox that's it......what more one can ask than local db on browser which has relational db system...so u can query it easily and handle complex data....which is very tougher in key vale based systems..

    I remember reading it even supports upto one gb.i am not sure....

    Note:

    1)I'd like to mention one point there is a IDE called Dashcode which let's u build web apps that looks like iOS native.even there also web SQL is used.

    2)actually web SQL is a implementation of SQLite on browsers.

    3)SQLite is most prefered in both iOS and android as db for native code..

    The drawbacks of SQLite:

    The Lack of concurrency support but which is not a problem in browser as it's gonna be used by single user at a time..this is a case also in mobile.

    Conclusions:

    Web Sql is abandoned by w3 that's a sad thing so we've to explore other options.

    0 讨论(0)
  • 2020-11-30 02:44
    CREATE TABLE IF NOT EXISTS table_name
    

    will create a table table_name only if if does not exist.

    0 讨论(0)
  • 2020-11-30 02:46

    I found the following WebSQL tutorials helpful for basic CRUD operations, as they contained examples, and explained what the code was doing:

    • A Simple TODO list using HTML5 WebDatabases
    • HTML5 Web SQL Database

    And the following links for SequelSphere (an HTML5 JavaScript SQL Relational Database Alternative to WebSQL that works in all browsers, storing data in LocalStorage and IndexedDB):

    • SequelSphere basic Usage instructions
    • API Documentation
    • Full Index of Guides and Helper Documentation
    0 讨论(0)
提交回复
热议问题