-
Notifications
You must be signed in to change notification settings - Fork 19
Inventory Filter Module
This filter module is used to extract a set of user-defined columns of a certain DB to be stored in the correspondent table file. A csv file is created for each table containing exported records. This files can then be used to, for instance, remove some records from a database.
When the filter receives the data structure that contains the database records, they come in three types of cells: Simple Cell, Binary Cell and Null Cell. To extract the data, only the Simple Cell are considered, while the others are marked as "N/A" in the generated csv files. In order to make a perfect combination between the column name, and the data to which it corresponds, the indexes in which they occur in the list of cells are saved, and then print the csv file with the correct information. When the user enters invalid parameters or in the wrong format, exceptions with error messages are thrown.
Produces a CSV file for each table that has annotated columns for export.
For example, for this configuration file, the result obtained is the generation of these two CSV files.
schemas:
sakila:
tables:
- name: "actor"
columns:
- name: "actor_id"
- name: "first_name"
inventory: true
- name: "last_name"
inventory: true
- name: "last_update"
where: ""
orderBy: ""
- name: "category"
columns:
- name: "category_id"
- name: "name"
inventory: true
- name: "last_update"
inventory: true
where: ""
orderBy: ""
Files obtained:
first_name,last_name
PENELOPE,GUINESS
NICK,WAHLBERG
ED,CHASE
JENNIFER,DAVIS
JOHNNY,LOLLOBRIGIDA
BETTE,NICHOLSON
name,last_update
Action,2006-02-15T04:46:27.000000Z
Animation,2006-02-15T04:46:27.000000Z
Children,2006-02-15T04:46:27.000000Z
Classics,2006-02-15T04:46:27.000000Z
The filter can be invoked without the need to add parameters. By default, the column headers of the CSV files will be printed, the separator will be a comma and the generated files will be saved in the home directory.
dbptk migrate -i <import-module> [args] -e [export-module] [args] -f inventory
dbptk migrate -i <import-module> [args] -e [export-module] [args] -f inventory -f1dir <path>
dbptk migrate -i <import-module> [args] -e [export-module] [args] -f imventory -f1pr <prefix>
dbptk migrate -i <import-module> [args] -e [export-module] [args] -f inventory -f1dh
dbptk migrate -i <import-module> [args] -e [export-module] [args] -f inventory -f1sp "<separator>"
By default, all columns are disabled for the extraction of the DB records. It is possible to explicit choose which columns to export. This can be done with the import-config module that can be consulted here.
Copyright © 2019 by KEEP SOLUTIONS
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the publisher, addressed “Attention: Permissions Coordinator,” at the address below.
KEEP SOLUTIONS, LDA.
Rua Rosalvo de Almeida, nº 5
4710-429 Braga, Portugal
W www.keep.pt E info@keep.pt