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
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 20, 2017 at 11:21 UTC
|
| [reply] [d/l] |
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 20, 2017 at 11:28 UTC
|
| [reply] |
|
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
| [reply] [d/l] [select] |
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
| [reply] |
|
#!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 | [reply] [d/l] |
Re^4: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 23, 2017 at 19:18 UTC
|
I get an error on line 17 "no such table: image" so i looked at the DB, and there is a table name 'image'. It's structured thusly:
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);
CREATE UNIQUE INDEX index_abcd on image (a, b, c, d);
CREATE INDEX index_tileset on image (tileset);
CREATE INDEX index_retrieved_tileset on image (retrieved, tileset);
So we open up the table image, and dump the field data, right?
#!perl
use strict;
use DBI;
my $database = 'MapTiles.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 data 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;
}
| [reply] [d/l] |
|
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: <%-{-{-{-<
| [reply] [d/l] [select] |
|
#!/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 | [reply] [d/l] |
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"
| [reply] [d/l] |
|
#!/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 | [reply] [d/l] |
|
| [reply] |
|
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
| [reply] [d/l] |
|
|
|
|