Data::Generator::FromDDL - Dummy data generator from DDL statements
use Data::Generator::FromDDL; my $generator = Data::Generator::FromDDL->new({ ddl => 'CREATE TABLE users (....);', parser => 'mysql', }); $generator->generate(100); # Generated data are written to STDOUT.
Data::Generator::FromDDL is dummy data generator intended to easily prepare dummy records for RDBMS. This module takes care of some constraints and generates records in the right order.
Supported constraints are
- PRIMARY KEY - UNIQUE KEY - FOREIGN KEY
Supported data types are
- BIGINT - INT (INTEGER) - MEDIUMINT - SMALLINT - TINYINT - FLOAT - DOUBLE - BOOLEAN (BOOL) - TIMESTAMP - CHAR - VARCHAR - TINYTEXT - TEXT - MEDIUMTEXT - ENUM
Data::Generator::FromDDL->new(%options);
Possible options are:
Description of DDL. This option is required.
Parser for ddl. Choices are 'MySQL', 'SQLite', 'Oracle', or 'PostgreSQL'.
Builder class.
Target tables.
Ignored tables.
$generator->generate($num, $out_fh, $format, $pretty, $bytes_per_sql);
Arguments are:
Number of records generated.
Or you can also give number of records for each table.
$num = {all => 20, # 20 records for all tables tables => { users => 10 # 10 records for 'users' table } };
This is useful for table that has one-to-many relationship with other table.
File handle object to which records are dumped.
Output format. Choices are 'sql' or 'json'.
Boolean value whether to print output prettily.
The maximum bytes of bulk insert statement.
This argument is releated to the MySQL's 'max_allowed_packet' variable which stands for the maximum size of string. It's recommended to suit this argument for your MySQL settings.
cf. https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_allowed_packet
The datagen_from_ddl(1) command is provided as an interface to this module.
datagen_from_ddl(1)
$ datagen_from_ddl --num=100 --parser=mysql --pretty your_ddl.sql
For more details, please see datagen_from_ddl(1).
Copyright (C) Yuuki Furuyama.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Yuuki Furuyama <addsict@gmail.com>
To install Data::Generator::FromDDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Generator::FromDDL
CPAN shell
perl -MCPAN -e shell install Data::Generator::FromDDL
For more information on module installation, please visit the detailed CPAN module installation guide.