Re: Problem using DB_File




"Andras Malatinszky" <nobody@xxxxxxxx> wrote in message
news:BOO8e.2262$lz1.1709@xxxxxxxxxxxxx
> I'm trying to read a database that I created using the DB_File module on
> a Linux box and then transferred to a Windows box. Here's a simplified
> setup illustration of my problem:
>
> First, on the Linux box I ran this script:
>
> #!/usr/bin/perl -w
> use strict;
> use DB_File;
>
> tie my %db, 'DB_File', 'database.db';
>
> $db{'blue'}='azul';
>
> untie %db;
>
>
> As expected, it creates a file called database.db, and when I run this
> script:
>
> #!/usr/bin/perl -w
> use strict;
> use DB_File;
>
> tie my %db, 'DB_File', 'database.db' or die $!;
>
> print $db{'blue'};
>
> untie %db;
>
>
> I get the word "azul" printed on the screen as expected.
>
> So now I FTP database.db and the second script over to my Windows box
> and run the script. What I get is an error message saying "Died at
> read.pl line 5." (Line 5 being the one with the tie.)
>
> Why is this happening? Why am I not getting anything in the $! variable?
> Does DB_File work with different formats on Linux and Windows? Any
> suggestions for addressing this, short of dumping the database on the
> Linux box and rebuilding it on the Windows box?

If compatible versions of Berkeley DB have been used to build DB_File on
both platforms, the database files are portable. In your case I would guess
that they aren't compatible.

Run this on the Linux box to see what version of Berkeley DB was used to
build DB_File

perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'

and this on the windows box

perl -e "use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}"

If the version numbers are identical, your problem lies elsewhere (possibly
an ASCII FTP).

If they are different, then you need to know which versions of Berkeley DB
are compatible with each other. To find that out, run the dbinfo script that
comes with DB_File against the database file on your Linux box. This script
will tell you what versions of Berkeley DB can be used to access the
database file. Usage is

perl dbinfo database_file

Assuming you have incompatible versions of Berkeley DB, you options are

1. rebuild DB_File on one/both platforms to use the same version of Berkeley
DB.
2. use the db_dump/db_load utilities that come with Berkeley DB to dump and
load the database.


Paul


.



Relevant Pages

  • Re: Flame Bait! Windows vs: The Unices
    ... I use the term "Linux" to refer to a typical ... > saying for a while about the advantages of Windows... ... Database server running on a remote machine. ... so I've decided to discuss /only/ programming (this ...
    (comp.programming)
  • Re: OK, stupid question about picture managment programs...
    ... I'm not interested in Linux. ... I'm a Windows developer, using VB.Net/ASP.Net ... I've been using Thumbs Plus on a trial basis, which has expired, but the ... I'd like some way of getting the full EXIF into the database. ...
    (rec.photo.digital)
  • Re: Flame Bait! Windows vs: The Unices
    ... Third, given access to the database, can ... The Microsoft focus on providing corporate business ... > probably longer than Linux has been around. ... trying to be MS Windows. ...
    (comp.programming)
  • Re: Filemaker/Access Linux alternative
    ... > In our small business we are looking at creating a new database for ... > Filemaker and my partner access. ... > Linux machines but can see the day where we'll keep a Mac OS X machine ... > or two for design and print work and replace Windows with Linux on the ...
    (comp.os.linux.misc)
  • Re: Advice needed: Where do I start with development (RAD) with DB access
    ... > stuff for Linux - so users will have to stay with Windows to use any app ... Must be able to interact with a PostgreSQL database over the net ...
    (Fedora)