在 Firefox 插件中创建 SQLite 数据库表的正确位置
非常简单:在 Firefox 插件中创建 SQLite 数据库表的“正确”位置是什么。
(如果可能的话,我想在安装插件时创建表)。
Very simply: What is the "correct" location to create SQLite database tables in a Firefox addon.
(If possible, I would like to create tables on installation of the addon).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好在开始使用数据库之前创建表。您不能假设执行一次(安装扩展时)就足够了 - 用户可能会出于某种原因删除您的数据库。所以你会做这样的事情:
这也是我在扩展更新时更新数据库结构的方式 - 如果打开数据库后你看到数据库结构已过时,那么你就更新它。这样,您将正确处理您的扩展已更新但数据库稍后由于备份正在恢复而降级的情况。
It is best to create tables right before you start using the database. You cannot assume that doing it once (when the extension is installed) is sufficient - the user might remove your database later for one reason or another. So you would do something like this:
This is also how I would update the database structure on extension updates - if after opening the database you see that the database structure is outdated then you update it. This way you will correctly handle the scenario that your extension was updated but the database was downgraded later at some point because of a backup being restored.