Firefox书签SQLite结构 [英] Firefox Bookmarks SQLite structure
问题描述
我正在尝试编写Firefox 3插件,使我能够轻松地重新标记书签.例如,我有一些标记为"development"的书签,另一些标记为"Development",并且我想要一种轻松地将所有"deelelopment"标签更新为"Development"的方法.不幸的是,我找不到执行此操作的加载项,因此我想自己创建一个.
I am trying to write a Firefox 3 add-on which will enable me to easily re-tag bookmarks. For example I have some bookmarks tagged "development" and some tagged "Development" and I would like a way to easily update all the "delelopment" tags to "Development". Unfortunately I can not find an add-on to do this so I thought I would create my own.
在我设法掌握基础知识并发现FireFox将所有书签存储在名为Places.sqlite的SQLite数据库中之前,还没有开发附加组件.在该数据库中,有一个名为moz_bookmarks的表,其中包含书签目录中的所有书签,标签和文件夹.书签文件夹及其子书签的结构使用外键ID表示,该ID指向同一表中父文件夹的ID,该表又向上递归到该父文件夹的ID,直到其到达书签根为止.
Having not developed an add-on before I've managed to grasp the basics and discovered that FireFox stores all bookmarks in an SQLite database called Places.sqlite. Within that database there is a table called moz_bookmarks which contains all the bookmarks, tags and folders within the bookmarks directory. The structure of the bookmark folders and their child bookmarks is represented using a foreign key id which points to the parent folder's id in the same table which again recursses upwards to that parent folder's Id until it hits the bookmarks root.
但是,让我感到困惑的是,您在firefox中应用的标签与书签之间的关系.每个标签的类型= 2,父ID =4.但是,我看不到它与使用该标签的实际书签之间没有相关性.如果我在Firefox中未添加特定书签的书签,但给它2或3个标签,则其父文件夹ID为5,对应于未归档",但看不到与其相关联的标签的进一步关联.
However, where I become stuck is how the tags you apply in firefox are related to the bookmarks. Each tag has a type = 2 and parent ID = 4. However I can see no correlation between this and an actual bookmarks that use the tag. If I add a bookmark in firefox to no particular folder but give it 2 or 3 tags then it's parent folder ID is 5 which corresponds to "unfiled" but I can see no further correlation to the tags associated with it.
我已经找到该结构上的Wiki页面,但实际上并没有帮助.
I have found this Wiki page on the structure but it does not really help.
这让我发疯:(请帮助...
It's driving me nuts :( Please help...
推荐答案
您可能已经发现自己了,但是标签的应用如下:
You probably already found out yourself, but tags are applied as follows:
数据库中所有URL的中心位置是moz_places
.表moz_bookmarks
通过外键列fk
进行引用.
The central place for all URLS in the database is moz_places
. The table moz_bookmarks
refers to it by the foreign key column fk
.
如果您标记书签,则moz_bookmarks
中会有多个条目,所有条目都具有相同的引用fk
:第一个是书签本身(在title
列中具有标题)对于每个标签,都有一个moz_bookmarks
中具有相同外键fk
并引用parent
列中的标签(指向标签的moz_bookmarks
行)的其他实体.
If you tag a bookmark, there are multiple entries in moz_bookmarks
, all having the same reference fk
: The first is the bookmark itself (having the title in the title
column) For each tag, there's an additional entriy in moz_bookmarks
having the same foreign key fk
and refering to the tag in the parent
coumn (which points to the moz_bookmarks
row for the tag).
如果您有一个标题为"Stackoverflow",标签为"programming"和"info"的书签" http://stackoverflow.com ",则您会得到:
If you have a bookmark 'http://stackoverflow.com' titled 'Stackoverflow' with tags 'programming' and 'info', you will get:
moz_places
----------
id url (some more)
3636 http://stackoverflow.com
moz_bookmarks
-------------
id type fk parent title (other columns omitted...)
332 1 3636 5 Stackoverflow (parent=5 -> unfiled folder)
333 2 (NULL) 4 programming (programming tag, parent=4 -> tags folder)
334 1 3636 333 (NULL) (link to 'programming' tag)
335 2 (NULL) 4 info (info tag, parent=4 see above)
336 1 3636 335 (NULL) (link to 'info' tag)
希望这对您有帮助...
Hope this helps...
这篇关于Firefox书签SQLite结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!