HOME | SOFTWARE | DataBase | Sql.pm PostgreSQL interface
Local Package Search:
Site Navagation
Browse Packages
Community Forum
Package Search
Package Maintainers
Mirror Listings
Submit Package
Documentation
Contact Info
Bug Tracker
Home and News
Sql.pm PostgreSQL interfaceSql.pm PostgreSQL interfaceSql.pm PostgreSQL interface

This Perl Module works with PG.pm to make the use of PostgreSQL without the PERL DBI simple and lightweight.

to install copy Sql.pm to /System/Library/Perl/ on OS X or site-perl on other platforms.

Construction of SQL is simple with SQL.pm
Always start your script with "use Sql;"
The following commands are supported:
  • $dbh=Sql::Open("dbname", "host"); ( creates a handle for the named database)
  • $value=Sql::Value($dbh,"select query that return only one value/string");
  • Sql::Query( $dbh, $query, \@results );
    foreach $record(@results){
    ($field1, $field2, .....) =split /\t /,$record;
    }

  • HQuery works like Query, but it returns an array of hashrefs instead of an array of delimited strings.
    Usage:
    Sql::HQuery( $dbh, $query, \@results );
    To see the results, dereference the array and hash with the name of one of the fields in the select statement:
    foreach my $r ( @results ) {
    print $r->{ "product_id" } . "\n";
    }
    Or:
    print ${$results[ 0 ]}{ "product_id" } . "\n";
    Caveat: HQuery uses the names of fields as hash keys, but those names do not include the table names.
    So if you do something like this:
    $query = "select table1.description, table2.description, ...";
    The "description" from one table will clobber the other "description".
    The solution is to use verbose field names or to not call both of them in one select statement.
    Or use Sql::Query.
  • Sql::Trans($dbh, $transaction, \@results);
  • $result=Sql::Sql($dbh, $sql); This command is for All non Query commands like insert, update, delete....
  • Sql::Close($dbh); close the Handle.
    Project Home: http://www.zarahemla.com/~chris/gnu/

    1 Package(s) found for Project: Sql.pm PostgreSQL interface

Valid HTML 4.01!