For Perl users - hope it helps somebody

From: "Leo" <fleovey(at)jus(dot)gov(dot)ar>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: For Perl users - hope it helps somebody
Date: 2008-07-10 13:54:27
Message-ID: 000601c8e294$7f6790b0$232401c8@leo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello
If you use Perl (like me) I have made a very nice set of small programs to access any database, any table and add, change or delete data.
I like it better than using Webmin or PgAdmin because I can easily customize the screens.

To get all database names and encoding:
my $dbh = DBI->connect("dbi:Pg:dbname=template1", "postgres", "postgres");
my $select = $dbh->selectall_arrayref("select datname,encoding from pg_database ORDER BY datname ") or die $DBI::errstr;

To get all tables in a base:
my $dbh = DBI->connect("dbi:Pg:dbname=$base", "postgres", "postgres");
my @tnames = $dbh->tables('');

To get the field names in a table (nice for updates):
my @header = @{$sth->{'NAME'}};
my @types = @{$sth->{'TYPE'}};

Hope somebody can use them

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Brian Hurt 2008-07-10 15:12:21 SQL "pseudo-variables" for a view
Previous Message Phillip Sitbon 2008-07-09 17:07:13 Re: Concurrent COPY commands