I'm working on a module that translates datetime sets into SQL statements. I'd appreciate to have your feedback on it.
----- NAME - DateTime::Format::SQL
SINOPSIS
my $formatter = DateTime::Format::SQL->factory; print $formatter->create_table( set => $set, table_name => 'MY_RECURRENCE', )->dump_sql;
METHODS
* factory
Creates a SQL formatter object.
my $formatter = DateTime::Format::SQL->factory ( format_datetime => sub { DateTime::Format::MySQL->format_datetime($_[0]) }, global_tables => { yearly => 'DT_YEARS', monthly => 'DT_MONTHS', }, );
The optional parameters are:
- format_datetime
A reference to a function that stringifies datetime objects.
- global_tables
A list of tables that already exist in the database. The new tables will be based on existing tables, whenever possible.
- start, end
Define a limiting span for tables.
The methods in the formatter object are:
* create_table
$formatter->create_table ( set => $set, table_name => 'MY_RECURRENCE', lazy => 1, );
If the optional "lazy" parameter is true, the program will try to create a space-efficient "VIEW" instead of a static "TABLE".
Views are automatically expanded when the base tables are updated.
Tables use less run-time CPU, but they take more storage space.
The method can also take optional "format_datetime", "start" and "end" parameters.
* get_sql
Iterates through the internal syntax tree, returning a SQL string at a time.
* dump_sql
Returns the SQL output as a single, possibly large, string.
-----
- Flavio S. Glock