Data-HandyGen-mysql

 view release on metacpan or  search on metacpan

script/hd_insert_bulk.pl  view on Meta::CPAN

        |-----+-------------+---------+
        | 501 |          50 |     101 |
        | 502 |          51 |     102 |
        | 503 |          51 |     101 |
        +-----+-------------+---------+

NOTE: ID can be omitted if it starts with 1 and is incremented one by one.

        "purchase" : {
            "1": { "customer_id" : "##customer.1", "item_id" : "##item.1" },
            "2": { "customer_id" : "##customer.2", "item_id" : "##item.1" },
            "3": { "customer_id" : "##customer.2", "item_id" : "##item.2" }
        }

is equivalent to:

        "purchase" : [
            { "customer_id" : "##customer.1", "item_id" : "##item.1" },
            { "customer_id" : "##customer.2", "item_id" : "##item.1" },
            { "customer_id" : "##customer.2", "item_id" : "##item.2" }
        ]

This is especially useful when those records won't be referenced from any other tables and you don't need to care about its ID.

=head1 OUTPUT

It will output all table names and IDs to STDOUT with YAML format like the followings:

    ---
    customer:
      - 50
      - 51
    item:
      - 101
      - 102
    purchase:
      - 501
      - 502
      - 503


You can use those values to delete test data. If you redirect the output to a file, you may later pass it to hd_delete_all.pl (included in this package) as an argument to delete those records.

    $ hd_insert_bulk.pl --infile example.json -d testdb -u myuser -p mypasswd > inserted.yml

    #  ...later

    $ hd_delete_all inserted.yml --i inserted.yml -d testdb -u myuser -p mypasswd
    (This will delete all records above)


=head1 TODO

=over 4

=item * To handle also YAML, CSV and TSV formats.


=back

=head1 BUGS AND LIMITATIONS

Please report problems to Takashi Egawa (C<< egawa.takashi at gmail com >>)
Patches are welcome.


=head1 SEE ALSO

L<Data::HandyGen::mysql>
L<hd_delete_all.pl>


=head1 AUTHOR

Takashi Egawa (C<< egawa.takashi at gmail com >>)


=head1 LICENCE AND COPYRIGHT

Copyright (c)2013 Takashi Egawa (C<< egawa.takashi at gmail com >>). All rights reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



( run in 0.709 second using v1.01-cache-2.11-cpan-39bf76dae61 )