Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

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


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

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

Replies are listed 'Best First'.
Re^6: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 24, 2017 at 22:14 UTC

    Ubuntu Yakkity

Re^6: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 24, 2017 at 22:21 UTC

    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

      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

        The script runs against TempMapTiles, which I assume is the output of the previous scripts right?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found