NAME
DBIx::Renderer - talk SQL by using Perl data structures
SYNOPSIS
use DBIx::Renderer ':all';
# mandatory name
use constant TYPE_MANDNAME => ( VARCHAR(255), NOTNULL );
my $struct = [
category => [
id => { TYPE_ID },
name => { TYPE_MANDNAME },
parent_id => { INT4, INDEX },
],
];
my $renderer = DBIx::Renderer::get_renderer('Postgres');
print $renderer->create_schema($struct);
DESCRIPTION
I got fed up with having to write different variants of SQL for different database engines. Also, I was looking for a way to specify a schema in Perl. The idea is that you construct data structures which are then rendered into the type of SQL appropriate for the target database server. Along the way we can make some optimizations and customizations, such as using database-specific features. For exmaple, we might make use of Postgres' array data types, but render them into weak relations for other servers.
Also, outputting the schema in XML might be useful.
EXPORTS
- :all
-
Exports all the
DBIx::Renderer::Constants
constants and functions, see its manpage for details.
FUNCTIONS
- get_renderer($name)
-
Requests construction of a specific DBI renderer. The renderer is constructed by called a
new()
constructor on the packageDBIx::Renderer::$name
.
TODO
- test.pl
-
Write test cases.
- Renderers
-
Extend with renderers for other databases, also have an XML renderer.
- Specify relationships
-
Allow specification of weak relations or, in fact, any sort of relations and have the necessary tables created automatically. This would be the first step in integrating it with something like
Class::DBI
.
BUGS
None known so far. If you find any bugs or oddities, please do inform the author.
AUTHOR
Marcel Grünauer <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
perl(1), DBI(3pm).