| Module Info
| Add a review of SQL-Abstract
It is good, very good.
What I would like is to see it in its own (dependencies free) package.
SQL::Abstract::Tree (which I do not use) brings a lot of unneeded stuff.
It will be great if one can install SQL::Abstract via cpan alone without SQL::Abstract::Tree.
Now it is possible to do so by just copying the Abstract.pm to your local lib directory, but this is not the "official approach".
Don't make the short-sighted mistake of discounting SQL::Abstract, because it doesn't do everything you need. While you can do joins, SQL::Abstract really shines in the generation of straight SQL for a single table. Since it takes simple (or complex) data structures as parameters, it is perfect for programatically generating SQL statements for select,update, insert, and delete queries. By using SQL::Abstract to generate SQL for all of my non-ClassDBI/DBIx::Class classes, I now have a consistent interface for all of my searching routines.
Love it! And, yes, we could put together a whole book of examples of how to use it. The syntax does get a little crazy when you want to do more -- especially with boolean logic.
Excellent way to make database work less tedious; writes your SQL for you, so you don't have to think about it.
May start to become awkward when your needs become more in-depth and you need big hairy queries, but for your average database work, this will handle it all with ease, and the interface is sane enough to avoid making you think.
I just found this handy little package. I've done SQL building here and there but never again. The best thing... the output of SQL::Abstract methods are a direct input for DBIx::Array.
$dbx->connect($connection, $user, $pass, \%opt);
my $count=$dbx->insert($sabs->insert($table, \%field));
my @data=$dbx->sqlarrayarray($sabs->select($table)); #whole table
I still need to find out how to use column aliases in the select.
I've used quite a few bits of code that try to represent SQL queries as structures of constraints. They generally range from painfully horrible to painfully naive. SQL-Abstract is really quite good. It's got almost everything I've needed, and then enough flexibility at the edges that I've rarely had to entirely circumvent it to get the job done.
I use SQL::Abstract heavily within and without Class::DBI, it allows me to assemble powerful queries from snippets and hashes of parameters and because it also provides the query, makes it simple to debug.
The documentation is good, but the abilities of SQL::Abstract excede what the documentation specifies, and although 9 times out of 10, it DWIM in absence of any specification of that behaviour in the documentation, sometimes the only way to see how to do something is to suck it and see, as they say in the documentation.
I think you could easily do with a pocket reference for this module alone, it has that much power and flexibility.
This module is very interesting, as it allows to keep your code "perlish" without inlining ugly SQL code.
It's nearly perfect, as subselects are not supported yet, but it is enough for most tasks. The where method can be used to create just the search statements, which will allow you to make queries with joins.
The DBIx::Class ORM relies on it and - in my opinion - SQL::Abstract gives the best when used inside DBIx::Class. It's - however - very useful anyhow.
This module is absolutely great if your needs in terms of SQL complexity are simple. It Just Works the way a Perl programmer would expect. You can be up and running in very little time; for small scripts automating simple tasks it's just what the doctor ordered.
Unfortunately, things start breaking apart if your needs are more complex. The resulting structures can be hard to visually parse and grok. There is no provision for subselects either, regardless of effort invested; it's just not possible to do them in its current state.
The documentation is generally well-written and helpful. It could be a little better organized (I often found myself spending too much time looking up things), but that is a somewhat minor quibble. Everything you need to know is in there somewhere.
I'd rate this module between 3 and 4 if it was possible, but it has definite potential to earn a 5.
This is one of my favorite modules; I use it all the time. There are
some quirks with how it works, but I think they are mostly because
SQL can get very hairy very quickly. Fortunately, SQL::Abstract
provides you with an escape route: The ability to use raw SQL for
the parts that are hard to do abstractly, while still keeping the
benefits of the abstraction.
SQL::Abstract is a nice alternative to the DBIx::Abstract module for providing a more Perl-like interface to creating SQL statements. Unlike DBIx::Abstract, SQL::Abstract does not use the database handle at all. It simply parses a Perl data structure and returns a SQL statement and appropriate bind variable.
This design gives you more flexibility to do something like a "prepare" a stement once, and then execute it over and over. This means that for something like doing a lot of inserts, SQL::Abstract can be exponentially faster than DBIx::Abstract.
I use the module for quickly creating large INSERT and UPDATE statements, as well as creating particular kinds of WHERE clauses.