LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1907|回复: 7

有没有什么工具能浏览Berkeley DB的数据?

[复制链接]
发表于 2006-6-17 12:33:30 | 显示全部楼层 |阅读模式
有没有什么工具能浏览Berkeley DB的数据?
 楼主| 发表于 2006-6-17 14:32:22 | 显示全部楼层
搞定了,db4.2_dump 可以浏览BDB文件的数据。
还有没有更好的工具呢?
回复 支持 反对

使用道具 举报

发表于 2006-6-18 15:57:48 | 显示全部楼层
自己写个程序
告诉我你的db的格式,我可以帮你搞定
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-6-18 17:06:59 | 显示全部楼层
非常感谢。
db文件是Moto A780的/ezxlocal/sysDatabase/native.db
这个文件保存了A780的号码簿、彩信、日程安排等内容。
这是 file native.db 的结果:
  1. native.db: Berkeley DB (Btree, version 9, native byte-order)
复制代码
这是 db4.2_dump -l native.db 的结果:
  1. 780_category_table
  2. 780_category_table.name
  3. 780_category_table.type
  4. 780_contact_table
  5. 780_contact_table.anniv id
  6. 780_contact_table.birth id
  7. 780_contact_table.email1
  8. 780_contact_table.email2
  9. 780_contact_table.fax
  10. 780_contact_table.first name
  11. 780_contact_table.home1
  12. 780_contact_table.home2
  13. 780_contact_table.last name
  14. 780_contact_table.mobile1
  15. 780_contact_table.mobile2
  16. 780_contact_table.name
  17. 780_contact_table.p2p1
  18. 780_contact_table.p2p2
  19. 780_contact_table.type
  20. 780_contact_table.work1
  21. 780_contact_table.work2
  22. 780_group2_table
  23. 780_group2_table.contact id
  24. 780_group2_table.field type
  25. 780_group2_table.group id
  26. 780_mapping_table
  27. 780_mapping_table.category name
  28. 780_mapping_table.id
  29. 780_mapping_table.name
  30. 780_mapping_table.type
  31. AS_CL_SettingTableName
  32. AS_CL_TABLE_NAME_0
  33. AS_CL_TABLE_NAME_0.LUID
  34. AS_CL_TABLE_NAME_0.operationType
  35. AS_CL_TABLE_NAME_0.seqNumber
  36. AS_CL_TABLE_NAME_0.serverClaim
  37. LOG_DATA_T
  38. LOG_DATA_T.dataType
  39. LOG_DATA_T.syncType
  40. SCHEMA
  41. SCHEMA_INDEX
  42. SYNCML_INFO_MAPPING_TBL
  43. SYNCML_INFO_MAPPING_TBL.dbType
  44. SYNCML_INFO_MAPPING_TBL.recLUID
  45. SYNCML_INFO_MAPPING_TBL.recStatus
  46. SYNCML_INFO_MAPPING_TBL.seqNumber
  47. SYNCML_INFO_MISC_TBL
  48. SYNCML_INFO_MISC_TBL.contactsDBSeqNumber
  49. SYNC_INFO_DATA_T
  50. SYNC_INFO_DATA_T.endSyncTime
  51. SYNC_INFO_DATA_T.lastSyncStatus
  52. SYNC_INFO_DATA_T.syncType
  53. TASKS_TABLE
  54. TASKS_TABLE.DALARM
  55. TASKS_TABLE.DUE
  56. TASKS_TABLE.PRIORITY
  57. TASKS_TABLE.SUMMARY
  58. WARN_DATA_T
  59. WARN_DATA_T.dataType
  60. WARN_DATA_T.syncType
  61. account
  62. account.AccountName
  63. account.IsDefaultAccount
  64. calendarDB
  65. calendarDB.ALARM
  66. calendarDB.DTSTAMP
  67. calendarDB.END
  68. calendarDB.REPEATEND
  69. calendarDB.START
  70. calendarDB_dst780_ex
  71. calendarDB_dst780_ex.ALARM
  72. calendarDB_dst780_ex.DTSTAMP
  73. calendarDB_dst780_ex.END
  74. calendarDB_dst780_ex.GLOBALID
  75. calendarDB_dst780_ex.MEETINGSTATUS
  76. calendarDB_dst780_ex.REPEATEND
  77. calendarDB_dst780_ex.START
  78. calendarExceptionDB_dst780_ex
  79. calendarExceptionDB_dst780_ex.ALARM
  80. calendarExceptionDB_dst780_ex.DTSTAMP
  81. calendarExceptionDB_dst780_ex.END
  82. calendarExceptionDB_dst780_ex.EXPDATE
  83. calendarExceptionDB_dst780_ex.GLOBALID
  84. calendarExceptionDB_dst780_ex.MEETINGSTATUS
  85. calendarExceptionDB_dst780_ex.PARENTUID
  86. calendarExceptionDB_dst780_ex.START
  87. cb_table_in_flash
  88. cb_table_in_flash.cb_fld_channel_number
  89. cb_table_in_flash.cb_fld_serial_number
  90. cb_table_in_flash.cmn_fld_folder_id
  91. cb_table_in_flash.cmn_fld_from_name
  92. cb_table_in_flash.cmn_fld_msg_type
  93. cb_table_in_flash.cmn_fld_msg_usage
  94. cb_table_in_flash.cmn_fld_send_receive_state
  95. cb_table_in_flash.cmn_fld_subject
  96. cb_table_in_flash.cmn_fld_time
  97. cb_table_in_flash.cmn_fld_time_msg_reach_phone
  98. cb_table_in_flash.cmn_fld_to_name
  99. ems_table_in_flash
  100. ems_table_in_flash.cmn_fld_folder_id
  101. ems_table_in_flash.cmn_fld_from_name
  102. ems_table_in_flash.cmn_fld_msg_type
  103. ems_table_in_flash.cmn_fld_msg_usage
  104. ems_table_in_flash.cmn_fld_send_receive_state
  105. ems_table_in_flash.cmn_fld_subject
  106. ems_table_in_flash.cmn_fld_time
  107. ems_table_in_flash.cmn_fld_time_msg_reach_phone
  108. ems_table_in_flash.cmn_fld_to_name
  109. folder
  110. folder.AccountID
  111. folder.FolderName
  112. folder.FolderSyncable
  113. folder.FolderType
  114. long_msg_table
  115. long_msg_table.tpdu_len
  116. mail
  117. mail.Date
  118. mail.FolderID
  119. mms_table_in_flash
  120. mms_table_in_flash.cmn_fld_folder_id
  121. mms_table_in_flash.cmn_fld_from_name
  122. mms_table_in_flash.cmn_fld_msg_type
  123. mms_table_in_flash.cmn_fld_msg_usage
  124. mms_table_in_flash.cmn_fld_send_receive_state
  125. mms_table_in_flash.cmn_fld_subject
  126. mms_table_in_flash.cmn_fld_time
  127. mms_table_in_flash.cmn_fld_time_msg_reach_phone
  128. mms_table_in_flash.cmn_fld_to_name
  129. mms_table_in_flash.mms_fld_msgid_name
  130. mms_table_in_flash.mms_fld_msguri_name
  131. msgctr_folder_table
  132. msgctr_folder_table.folder_id
  133. msgctr_folder_table.show_order_no
  134. msgctr_folder_table.userdef_folder_name
  135. wap_msg_table_in_flash
  136. wap_msg_table_in_flash.cmn_fld_folder_id
  137. wap_msg_table_in_flash.cmn_fld_from_name
  138. wap_msg_table_in_flash.cmn_fld_msg_type
  139. wap_msg_table_in_flash.cmn_fld_msg_usage
  140. wap_msg_table_in_flash.cmn_fld_send_receive_state
  141. wap_msg_table_in_flash.cmn_fld_subject
  142. wap_msg_table_in_flash.cmn_fld_time
  143. wap_msg_table_in_flash.cmn_fld_time_msg_reach_phone
  144. wap_msg_table_in_flash.cmn_fld_to_name
  145. wap_msg_table_in_flash.wap_fld_expiry_time
  146. wap_msg_table_in_flash.wap_fld_final_id
复制代码
你说的格式是数据库的结构吗?我怎么才能得到数据库的结构呢?
回复 支持 反对

使用道具 举报

发表于 2006-6-18 18:17:26 | 显示全部楼层
其实就是这句话里面的
"native.db: Berkeley DB (Btree, version 9, native byte-order)"

的Btree字段.

我把程序代码贴上去,你自己需要用gcc编译一下
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-6-18 18:24:18 | 显示全部楼层
好的,等待你的代码。
非常感谢。
回复 支持 反对

使用道具 举报

发表于 2006-6-18 18:30:58 | 显示全部楼层
//程序代码如下:
/*编译的时候要用-L 参数指定你的libdb.so和libdb.a的位置,并且db.h的头文件的位置也需要用-i参数指定.这个和你的系统和安装Berkeley DB的位置不同而不同.
例如我的编译参数,我用的是Berkeley DB 4.4并且安装在/usr/local/BerkeleyDB.4.4目录下:
gcc -o ReadBDB -l db ReadBDB.c -I /usr/local/BerkeleyDB.4.4/include/ -L /usr/local/BerkeleyDB.4.4/lib

*/
#include <stdio.h>
#include <db.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[])
{
        DB* dbp;
        DBT key, data;
        int ret;
        DBC* cur;

        if (argc<1)
        {
                printf("Usage: ReadBDB <db's filename>\n");
                exit (1);
        }
        if (argc>=1)
        {
                if (argv[1]==0) //to judge argv[1] NULL
                {
                        printf("Usage: ReadBDB <db's filename>\n");
                        exit (1);
                }

        }
        if ((ret=db_create(&dbp, NULL, 0))!=0)
        {
                dbp->err(dbp, ret, argv[1]);
                exit(1);
        }
        if ((ret=dbp->open(dbp, NULL, argv[1], NULL, DB_BTREE, DB_RDONLY, 0664))!=0)
        {
                dbp->err(dbp,ret, argv[1]);
                exit(1);
        }

        dbp->cursor(dbp, NULL, &cur, 0);

        memset(&key, 0, sizeof(DBT));
        memset(&data, 0, sizeof(DBT));

        while ((ret=cur->c_get(cur, &key, &data, DB_NEXT))==0)
        {
                printf("%s:%s\n", (char*)key.data, (char*)data.data);
                memset(&key, 0, sizeof(DBT));
                memset(&data, 0, sizeof(DBT));
        }

        cur->c_close(cur);
        dbp->close(dbp, 0);
}
回复 支持 反对

使用道具 举报

发表于 2006-6-18 18:32:37 | 显示全部楼层
呵呵,我用Berkeley DB都是在大型应用中,不过一直听说这个东东在嵌入式系统中有广泛应用,看来果然如此.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表