Extract subtrees of data from relational databases.
1.0K
Tree of data may be for example some user account and all records in related tables that belong to him. Useful for cases like:
For full documentation see README.
You have MySQL database and you need to extract user from users table having id = 1 with all his data from related tables.
Create working directory for scripts and output files, for example:
mkdir /Users/me/uprooted
Run Docker and mount this directory.
docker run --interactive --tty --volume /Users/me/uprooted:/home/uprooted bbkr2/uprooted:latest
Create example.raku file in this directory with following content (adjust lines marked with comments):
use DBIish;
my $connection = DBIish.connect(
'mysql',
host => '***', port => 3306, user => '***', password => '***', database => '***' # adjust connection credentials
);
use UpRooted::Schema::MySQL;
my $schema = UpRooted::Schema::MySQL.new( :$connection );
use UpRooted::Tree;
my $tree = UpRooted::Tree.new( root-table => $schema.table( 'users' ) ); # adjust table name
use UpRooted::Reader::MySQL;
my $reader = UpRooted::Reader::MySQL.new( :$connection, :$tree );
use UpRooted::Writer::MySQLFile;
my $writer = UpRooted::Writer::MySQLFile.new;
$writer.write( $reader, id => 1 ); # adjust Primary Key / Unique Key field name
Run your script:
raku example.raku
Your user will be saved to out.sql file in /Users/me/uprooted directory.
If you run into a problem with UpRooted please report it.
Content type
Image
Digest
sha256:7fd35d2f5…
Size
245 MB
Last updated
almost 4 years ago
docker pull bbkr2/uprooted