LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What is the preferred way to view the contents of a Berkeley DB file? - SuSE 9.3 Box (https://www.linuxquestions.org/questions/linux-general-1/what-is-the-preferred-way-to-view-the-contents-of-a-berkeley-db-file-suse-9-3-box-889401/)

EnderX 07-01-2011 11:01 AM

What is the preferred way to view the contents of a Berkeley DB file? - SuSE 9.3 Box
 
As the topic title states, I would like to know the preferred way of viewing the contents of a Berkeley DB file. The machine the file is on is running SuSE 9.3, with perl 5.8.6 and php 5.2.0 installed. (I'm not sure if stating that was necessary, but my understanding is that the more information I can provide you, the better. If I am wrong in this, I apologize.)

The purpose to this question is this: I have been requested to look into coming up with some form of Geocoding software for one of my company's clients. Specifically, I've been requested to look into trying to obtain Census tract/block information.

I discovered the Perl module Geo::Coder::US, which uses Census input (TIGER\Line files) to create a Berkeley DB file, then reads said file to produce its own output. However, the output from Geo::Coder::US only provides latitude and longitude information.

At the moment, my only interest is in popping the Berkeley DB file generated with the import script packaged with the Geo::Coder::US module. I'm trying to see what the contents of that DB file are, so I can determine if the information I'm after is even in there in the first place.

Please forgive me if this is a question with a too-obvious answer. I've only worked with MySQL and PostgreSQL before, so I know nothing about Berkeley DB systems.

Peacedog 07-02-2011 02:33 PM

Hi EnderX, You may want to try db-utils, particularly db_dump.

Good luck. ;-)

aysheaia 07-02-2011 03:12 PM

You can, for example, use the BerkeleyDB perl module to parse le content of the database :
Code:

$ cat parse-db.pl
        use BerkeleyDB;
        my $env = new BerkeleyDB::Env
                  -Home => "/database_directory/";
        my $db = new BerkeleyDB::Hash
                  -Filename => "database_file.db",
                  -Env => $env
          or die "cannot open database: $BerkeleyDB::Error\n";
        my $cursor = $db->db_cursor();
        while ($cursor->c_get($key, $value, DB_NEXT) == 0) {
          print "$key -> $value\n";
        }



All times are GMT -5. The time now is 04:29 AM.