Bug#1127330: Provide a converter from BerkeleyDB to SQLite
Marco d'Itri
md at linux.it
Sat Feb 7 01:17:50 GMT 2026
Package: animals
Version: 202601041054Z-1
Severity: important
Tags: patch
Here it is.
--
ciao,
Marco
-------------- next part --------------
#!/usr/bin/perl
# Conversion program written by Marco d'Itri <md at linux.it>.
# SPDX-License-Identifier: GPL-2.0-or-later
#
# apt install libberkeleydb-perl
# animals_dump | sqlite3 animals.sqlite3
use v5.36;
use BerkeleyDB;
my $db_file = '/var/games/animals/animals.db';
my %animals;
my $db = tie(%animals, 'BerkeleyDB::Btree',
-Filename => $db_file,
-Flags => DB_RDONLY,
) or die "Cannot open DB $db_file: $BerkeleyDB::Error";
$db->filter_fetch_key (sub { s/\0$// });
$db->filter_fetch_value(sub { s/\0$// });
$db->filter_store_key (sub { $_ .= "\0" });
$db->filter_store_value(sub { $_ .= "\0" });
print << 'END';
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE animals (key VARCHAR(255) NOT NULL PRIMARY KEY, value VARCHAR(255) NOT NULL);
END
foreach my $key (keys %animals) {
my $value = $animals{$key};
$value =~ s/'/''/g;
say qq{INSERT INTO animals VALUES('$key','$value');};
}
print << 'END';
COMMIT;
END
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-games-devel/attachments/20260207/ba61dd19/attachment.sig>
More information about the Pkg-games-devel
mailing list