Ok, try this

#!perl use strict; use DBI; my $database = 'TestMapTiles.sqlitedb'; my $tablename = 'image'; # open db my $dbh = open_db($database); my $imgfolder = 'maptiles-output'; if (! -d $imgfolder){ mkdir($imgfolder, 0755) or die "$!"; } # select data my $sql = 'SELECT * from '.$tablename; my $sth = $dbh->prepare($sql); $sth->execute(); # recreate files # 0..3 a int, b int, c int, d int, # 4..6 tileset int, retrieved int, current bool, # 7..9 etag text, size int, data blob, open LOG,'>',$tablename.'.dat'; while (my @f = $sth->fetchrow_array){ print LOG join "\t",@f[0..8],"\n"; my $pk = join '_',@f[0..3]; # a_b_c_d primary key my $filename = "$imgfolder/$pk.png"; # my $filename = "$imgfolder/$x,$y\@$zoom.png"; print "creating $filename\n"; open OUT,'>:raw',$filename or die "$filename : $!"; print OUT $f[9]; # data blob close OUT; } close LOG; # open db sub open_db { my $dbfile = shift; my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", # dbname = $dbfile was my mistake "", "", { RaiseError => 1 } ) or die $DBI::errstr; return $dbh; }

I can't map your filename variables $x,$y\@$zoom.png to the fieldnames so I have used the primary key fields a_b_c_d. All the data (except the blob) should be in the log file image.dat. Maybe you can determine which fields are the x,y map co-ordinates and zoom level.

poj

In reply to Re^7: help figuring out what a section of script does by poj
in thread help figuring out what a section of script does by michaelsingleton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.