在webapp中复制SQLite数据库 [英] Duplicate SQLite database in webapp
本文介绍了在webapp中复制SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在移动网络应用程序中创建数据库,唯一的问题是Safari每次刷新网站时都会创建一个新的数据库。
这是我的代码:
I'm trying to create a database in a mobile webapp, the only problem is Safari creates a new database every time I refresh the website. Here is my code:
var databaseOptions = {
fileName : "todo_database",
version : "1.0",
displayName : "todoDB",
maxSize : 1024
};
var database = openDatabase(databaseOptions.fileName, databaseOptions.version,
databaseOptions.displayName, databaseOptions.maxSize);
database.transaction(function(transaction) {
alert('table created');
transaction.executeSql("CREATE TABLE IF NOT EXISTS todos (" +
"id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," +
"todo TEXT NOT NULL,description TEXT,date DATE);");
});
推荐答案
这实际上不是代码的问题,它似乎是Safari for Windows中的一个错误,如果我关闭浏览器只剩下一个数据库并且包含所有信息。
It actually was not a problem with the code, it seems to be a bug in Safari for Windows, if I close the browser only one database remains and with all the information.
这篇关于在webapp中复制SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文