http://qs321.pair.com?node_id=621393

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

Hi All,
  For some time I've been planning a perl module that makes interacting with any of the above databases much easier. Basically it would give you a common SQL syntax to use and make the necessary syntax changes for you. I though as I had planned it, there was a good chance it's already been done, although I cannot find anything in CPAN. Anyone know of a module that does it?
  • Comment on MySQL, MS SQL, PostgreSQL - Common interface

Replies are listed 'Best First'.
Re: MySQL, MS SQL, PostgreSQL - Common interface
by andreas1234567 (Vicar) on Jun 15, 2007 at 05:32 UTC
    You mean besides DBI?

    The different database engines are exactly that: different. They implement basic features, such as DATE and TIME in the SQL standard differently. See this article.

    Furthermore, for better concurrency, many database engines require the use of a database specific programming language: PL/SQL (Oracle), SQL PL (IBM DB2), even MySQL has this ability as of version 5.0. While there's some similarities within these languages, they are highly incompatible. So I would say what you are trying to do is very difficult.

    Why is database independence so important?

    --
    print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})
Re: MySQL, MS SQL, PostgreSQL - Common interface
by Tomte (Priest) on Jun 15, 2007 at 10:01 UTC

    Well, I'd say if you're going to abstract from SQL up, abstract the whole way to an OO-View where you don't use SQL itself anymore - but if you are determined to write such a module - which could be very useful indeed - I suggest to take a look at the SQLFairy (SQL::Translator) - they have done such a thing already - you could use SQL::Translator on-the-fly, or at least prey upon it to reuse their effort.

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      I'd say if you're going to abstract from SQL up, abstract the whole way to an OO-View where you don't use SQL itself anymore ...

      I could never understand why would anyone want to do that, but that's just me.

Re: MySQL, MS SQL, PostgreSQL - Common interface
by DrHyde (Prior) on Jun 15, 2007 at 10:03 UTC
    Take a look at SQL::Statement and its friends and relations. No promises cos I've not used it myself, but at least the module names look like they might be right :-)
Re: MySQL, MS SQL, PostgreSQL - Common interface
by guinex (Sexton) on Jun 15, 2007 at 11:26 UTC