Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: help figuring out what a section of script does

by michaelsingleton (Novice)
on Mar 19, 2017 at 15:35 UTC ( [id://1185185]=note: print w/replies, xml ) Need Help??


in reply to Re: help figuring out what a section of script does
in thread help figuring out what a section of script does

Sure! There are two BLOB fields, and I think this one is the image data (as it's labeled 'image' lol)

 564D50340000070001004E0000000A0000000A0058000000850000000B00DD0000000B0000001400E80000001C0300001F0004040000AA0000003C00AE040000

Replies are listed 'Best First'.
Re^3: help figuring out what a section of script does
by poj (Abbot) on Mar 19, 2017 at 21:12 UTC

    The start of that string is VMP4 in ASCII. It that the complete data or just a part of it ?

    poj

      Sorry! I posted the wrong part from SQLDB Viewer. Is this better?

      564D50340000070001004E0000000A0000000A0058000000850000000B00DD0000000B0000001400E80000001C0300001F0004040000AA0000003C00AE040000C80000003300760500008A00000000370008D000032680F00196000000789C4DC95D0AC2300C00E01C255798207B9E1

      Every entry in the DB with this BLOB data starts with VMP4. So is it not really binary data?

        So is it not really binary data?

        I don't know, what was the name of the database and the table that the data was dumped from ?

        Was it images from MapTiles.sqlitedb ?

        poj

      Yes, that is correct. I'm going to try SQL::Parser instead of the manual decoding and see how that goes

        Do you have a copy of the database or just a dump file ?

        If you have the database try this

        #!perl use strict; use DBI; my $database = 'MapTiles.sqlitedb'; my $tablename = 'images'; # 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 while (my ($zoom, $x, $y, $flags, $length, $data) = $sth->fetchrow_arr +ay){ my $filename = "$imgfolder/$x,$y\@$zoom.png"; print "creating $filename\n"; open OUT,'>:raw',$filename or die "$filename : $!"; print OUT $data; close OUT; } # open db sub open_db { my $dbfile = shift; my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "", { RaiseError => 1 } ) or die $DBI::errstr; return $dbh; }
        Update : dbname = $dbfile corrected
        
        poj

        This node is a properly formatted copy of an entirely unformatted (and now considered, and perhaps already reaped) previous node. It wasn't necessary to post a copy of the previous node in order to correct the formatting lapse. By editing the previous node to add  <code> tags as appropriate, the lack of formatting could have been corrected. Please see the Edit and edit links in your posts, and also How do I change/delete my post?.

        (Actually, even this post isn't entirely properly formatted IMHO: the DB statements  CREATE TABLE image ...; ...; CREATE INDEX index_retrieved_tileset ...; should also be <code>-wrapped. :)


        Give a man a fish:  <%-{-{-{-<

        What do you get running this

        #!/usr/bin/perl use strict; use DBI; my $dbfile = 'MapTiles.sqlitedb'; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); print join "\n",$dbh->tables;
        poj
      "main"."edition" "main"."image" "main"."image" "main"."image" "main"."image" "main"."sqlite_master" "temp"."sqlite_temp_master" "main"."edition" "main"."image" "main"."version"

        I don't know why you have duplicates, try this

        #!/usr/bin/perl use strict; use DBI; my $dbfile = 'MapTiles.sqlitedb'; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); my $sth = $dbh->table_info('%', '%', '%'); while (my $r = $sth->fetchrow_hashref()) { print join " ",$_,$r->{$_},"\n" for keys %$r; print "\n"; }

        Which Operating System are you using ?

        poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-20 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found