Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Inserting binary data into MySQL

by Zaxo (Archbishop)
on Sep 17, 2003 at 00:38 UTC ( [id://292010]=note: print w/replies, xml ) Need Help??


in reply to Inserting binary data into MySQL

You can read a file in fixed-length chunks by setting $/ to a reference to an integer

{ use bytes; local $/ = \1048576; open my $fh, '<', 'bigfile.bin' or die $!; while (<$fh>) { # stuff the db } }
To reconstruct your file you can either concatenate the blobs in memory, or write them to a file. In either case you need a way to retain their order, which the db can do if you make a column to remember it by. To check that things go ok, all you really need is to set RaiseError in the DBI handle.

After Compline,
Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-23 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found