in reply to array as mysql db rows

No local MySQL but with DBI and SQLite this works:

#!/usr/bin/perl -w use strict; use DBI; use MIME::Base64; my $dbh = DBI->connect('DBI:SQLite:dbname=test_blob.db', '', ''); $dbh->do('CREATE TABLE test_blob( a text , b text , Bindata BLOB )'); my $bindata = "ABC" . qq|\x00| . "DEF"; #added $bindata = encode_base64($bindata); my $sth1 = $dbh->prepare('INSERT INTO test_blob VALUES(?,?,?)' ); my @ar = qw|foo doog|; $sth1->execute(@ar, $bindata); my $sth2 = $dbh->prepare('SELECT Bindata FROM test_blob'); $sth2->execute(); my $row = $sth2->fetch(); my $fetched_data = $row->[0]; $sth2->finish(); $dbh->disconnect; print decode_base64($fetched_data); 1;

And from the database:

.schema test_blob CREATE TABLE test_blob( a text , b text , Bindata BLOB ); sqlite> select * from test_blob; foo|doog|QUJDAERFRg==

That code you posted had all sorts of other problems so I grabbed the above from a previous post. Update: Come to think of it, you could replace that SQL creation code with something like:

perl -e "$lf = @ARGV;$sql= 'insert into BLAH (' . eval{join ',',@ARGV +} . ') VALUES (' . eval{join ',', split//,'?' x $lf} . ')'; print $sq +l;" DOGS CATS FISH ANIMALS TRIKES KITES insert into BLAH (DOGS,CATS,FISH,ANIMALS,TRIKES,KITES) VALUES (?,?,?,? +,?,?)

Celebrate Intellectual Diversity