Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

DBD::Mysql Messing with my data?

by opuz (Initiate)
on Feb 07, 2004 at 20:44 UTC ( [id://327366]=perlquestion: print w/replies, xml ) Need Help??

opuz has asked for the wisdom of the Perl Monks concerning the following question:

I've just setup a new system, fresh copy of perl, and DBD::Mysql. I've got a database with a bunch of zip files. On my old system I could extact the zips without a problem but from this new system they all appear to have extra data. So for example this simple piece of code works fine on one system but not the other.
use DBI; $dbh = DBI->connect("dbi:mysql:mydb;192.168.3.4","root","password"); $sth2 = $dbh->prepare("select data from inbound where inboundid=1234") +; $rv2 = $sth2->execute; %inbound = %{$sth2->fetchrow_hashref}; open(ZIP, ">data.zip"); print ZIP $inbound{'data'}; close(ZIP); result: New system - -rw-r--r-- 1 root root 5928 Feb 7 2004 temp.zip Old system - -rw-r--r-- 1 root root 4000 Feb 7 2004 temp.zip
Is there something in perl or in DBD::Mysql that could do this? The new system is running: perl v5.8.0 and DBD::Mysql 2.9003 The database hasn't changed. This is driving me crazy. Any suggestions?

Replies are listed 'Best First'.
Re: DBD::Mysql Messing with my data?
by kvale (Monsignor) on Feb 07, 2004 at 20:55 UTC
    Well, first of all, you wrote to data.zip, not temp.zip, so check data.zip in your directory for the file sizes.

    Assuming there is still a difference in sizes, I would recommend working backward from the endpoint of your computation. Is  $inbound{'data'} the same length in both cases? Compare unzipped archives to see if data has been truncated or added. If something has been added, look at the extra stuff with a hex editor.

    -Mark

      My bad. temp.zip/data.zip same thing. The row in the database is not changing, both systems are selecting the same data. But you made a good suggestion. If I say:
      print length($inbound{'data'});
      Both systems have an identical byte size. So infact it's not DBD::Mysql at all. It's happening when I write the data to the file. What would cause perl to write out extra binary data?

        Do both systems have the same locale settings? Does one system need binmode on the output filehandle? Can you provide the versions of the operating systems on both systems?

        Have you tried setting binmode on the file handle? What operating system are you working on?

        90% of every Perl application is already written.
        dragonchild
Re: DBD::Mysql Messing with my data?
by bart (Canon) on Feb 08, 2004 at 10:16 UTC
    It sounds like on the second db, your fetched data is truncated. Exactly 4000 bytes? That doesn't sound like a coincidence.

    Look up "LongReadLen" and "LongTruncOk" in the DBI docs. I'm quite sure that holds the key to your problem.

Re: DBD::Mysql Messing with my data?
by michellem (Friar) on Feb 08, 2004 at 00:07 UTC
    This might be way, way off the mark, but has zip changed? Is there a possibility that the different version of zip in the two systems is giving this result?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://327366]
Approved by pfaut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-19 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found