Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by poj (Abbot)
on Mar 19, 2017 at 21:12 UTC ( [id://1185205]=note: print w/replies, xml ) Need Help??


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

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

poj

Replies are listed 'Best First'.
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 20, 2017 at 11:21 UTC

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

    564D50340000070001004E0000000A0000000A0058000000850000000B00DD0000000B0000001400E80000001C0300001F0004040000AA0000003C00AE040000C80000003300760500008A00000000370008D000032680F00196000000789C4DC95D0AC2300C00E01C255798207B9E1
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 20, 2017 at 11:28 UTC

    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
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 21, 2017 at 13:08 UTC

    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
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 23, 2017 at 19:18 UTC

      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
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 24, 2017 at 21:00 UTC
    "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

        Ubuntu Yakkity

        Output of your second request

        TABLE_SCHEM main TABLE_TYPE INDEX TABLE_CAT sqlite_sql REMARKS TABLE_NAME edition TABLE_TYPE INDEX REMARKS sqlite_sql TABLE_CAT TABLE_NAME image TABLE_SCHEM main TABLE_SCHEM main TABLE_TYPE INDEX TABLE_CAT sqlite_sql CREATE UNIQUE INDEX index_abcd on image (a, b, c, d) REMARKS TABLE_NAME image TABLE_TYPE INDEX sqlite_sql CREATE INDEX index_tileset on image (tileset) TABLE_NAME image REMARKS TABLE_CAT TABLE_SCHEM main REMARKS sqlite_sql CREATE INDEX index_retrieved_tileset on image (retrieved, t +ileset) TABLE_NAME image TABLE_CAT TABLE_TYPE INDEX TABLE_SCHEM main REMARKS sqlite_sql TABLE_NAME sqlite_master TABLE_CAT TABLE_TYPE SYSTEM TABLE TABLE_SCHEM main TABLE_SCHEM temp TABLE_NAME sqlite_temp_master sqlite_sql REMARKS TABLE_CAT TABLE_TYPE SYSTEM TABLE TABLE_SCHEM main TABLE_CAT sqlite_sql CREATE TABLE edition (tileset int, edition int, unique (til +eset)) REMARKS TABLE_NAME edition TABLE_TYPE TABLE TABLE_SCHEM main TABLE_TYPE TABLE sqlite_sql CREATE TABLE image (a int, b int, c int, d int, tileset int +, retrieved int, current bool, etag text, size int, data blob, UNIQUE +(a, b, c, d) ON CONFLICT REPLACE) REMARKS TABLE_NAME image TABLE_CAT TABLE_SCHEM main TABLE_TYPE TABLE sqlite_sql CREATE TABLE version (version int, locale text) REMARKS TABLE_NAME version TABLE_CAT

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found