http://www.perlmonks.org?node_id=839885

benizi has asked for the wisdom of the Perl Monks concerning the following question:

I've been using DBI + SQL::Abstract for a lot of stuff, and one of the things I need to do now is generate concrete SQL scripts. For example, SQL::Abstract makes converting a hash into an insert extremely simple:

my $dbh = DBI->connect(@params); my $gen = SQL::Abstract->new; my ($insert, @bind) = $gen->insert(atable=>{a=>undef,b=>1,c=>'string'} +); my $sth = $dbh->prepare($insert); $sth->execute(@bind); __END__ $insert eq "INSERT INTO atable ( a, b, c) VALUES ( ?, ?, ? )" @bind contains undef, 1, "string"

But, now I have an occasion where I need to get parameter-free SQL to execute in a (My)SQL script. E.g., given the above example, I'd like to turn $insert and @bind back into:

INSERT INTO atable ( a, b, c) VALUES ( NULL, 1, 'string' )

Part of the problem is terminology. The only keywords I can think of { SQL, literal, abstract, bind, parameters, quoting } all get tons of results in the direction I've been using SQL::Abstract. (That is: ways to use tools like DBI that promote the use of placeholders, etc.)

I'm wondering whether there's a DBD driver that will do this. (e.g. change the connect string to something like 'DBI:fakesql:dialect=mysql', where 'fakesql' is the module I'm unable to find) Or is there another tool that I'm overlooking?