开发者

Can't create more than one table with Websql/Chrome

开发者 https://www.devze.com 2023-01-29 05:25 出处:网络
I can\'t create more than one table on a Chrome App dadabase Here is a snippet of the code: lk.webdb.open = function() {

I can't create more than one table on a Chrome App dadabase Here is a snippet of the code:

lk.webdb.open = function() {
  var dbSize = 10 * 1024 * 1024; // 10MB
  lk.webdb.db = openDatabase("SSW3", "1.0", "SEO SERP Workbench", dbSize);
}

lk.webdb.createTable = function() {
var db = lk.webdb.db;
db.transaction(function(tx) {
  tx.executeSql("CREATE TABLE IF NOT EXISTS items (ID INTEGER PRIMARY KEY ASC, setid INTEGER , day DATETIME , engine TEXT, query TEXT , url TEXT , position INTEGER )", []);
  tx.executeSql("CREATE TABLE IF NOT EXISTS sets (ID INTEGER PRIMARY KEY ASC, name TEXT )", []);
  });
}

The table items is created, if not existing, the table sets never gets created.

Moreover, before trying this, I wanted to create multiple items tables, named items1,items2,etc depending on the active user project, but again, when the database has no tables, the first is created, but not any other.

Looking in the web and the W3C docs I haven't found ONE ex开发者_如何学Pythonample of creating more than one table, but looks like only one table can be created for each DB (that's absurd) or I'm simply doing things in the wrong way ...


I ran the following code and had no problems in creating both tables:

var db = openDatabase("SSW3", "1.0", "SEO SERP Workbench", 10 * 1024 * 1024);
db.transaction(function (tx) {
  tx.executeSql("CREATE TABLE IF NOT EXISTS items (ID INTEGER PRIMARY KEY ASC, setid INTEGER , day DATETIME , engine TEXT, query TEXT , url TEXT , position INTEGER )", []);
  tx.executeSql("CREATE TABLE IF NOT EXISTS sets (ID INTEGER PRIMARY KEY ASC, name TEXT )", [] );
});
0

精彩评论

暂无评论...
验证码 换一张
取 消