Обсуждение: DBI
Hi. I need to know if I configure my psql with perl library I also need
the DBI::Pg class for quering my database in psql?. The following example
will work?
------
use DBI;
$dbh = new DBI( 'dbi:Pg:database;host', 'user', 'secret' );
if( ! $dbh->dbh ){
echo "Could not connect to the database.<br>\n";
exit( );
}
$sth = $dbh->prepare( 'SELECT COUNT(*) FROM some_table' );
and sow on...
------
What else do I need to install for quering a database in this way?
I did not installed yet Psql to know if will works.
Sorry, but my english it's not so god.
Cosmin.
______________________________________________________________________
Do you want a free e-mail for life ? Get it at http://www.email.ro/
______________________________________________________________________
Do you want a free e-mail for life ? Get it at http://www.email.ro/
>>>>> "EC" == Ene Cosmin <cosmox@email.ro> writes:
EC> Hi. I need to know if I configure my psql with perl library I also need
EC> the DBI::Pg class for quering my database in psql?. The following example
EC> will work?
EC> ------
EC> use DBI;
EC> $dbh = new DBI( 'dbi:Pg:database;host', 'user', 'secret' );
EC> if( ! $dbh->dbh ){
EC> echo "Could not connect to the database.<br>\n";
EC> exit( );
EC> }
EC> $sth = $dbh->prepare( 'SELECT COUNT(*) FROM some_table' );
EC> and sow on...
EC> ------
EC> What else do I need to install for quering a database in this
way?
It seems to me your example is right.
So you need modules: Pg (installs together with postgresql), DBI and
DBD::Pg.
--
Anatoly K. Lasareff Email: tolik@aaanet.ru
http://tolikus.hq.aaanet.ru:8080 Phone: (8632)-710071
> Hi. I need to know if I configure my psql with perl library I also need >the DBI::Pg class for quering my database in psql?. The following example >will work? if you vconfigure postgresql with --with-perl, the "native" Pg Module is built. This one differs a bit from DBI::Pg. For me, I do not have DBI::Pg installed, but Pg, and I am using it successfully. If you want do use DBI::Pg, you'll have to install it from CPAN. Stefan
Thanks for the answer. Where can I find this modules: DBI and DBD::Pg are classes ...?>? sorry.... i don't know how to do it...i really nead to know for a university project!! ... and why can I acces your webpage? > http://tolikus.hq.aaanet.ru:8080 ______________________________________________________________________ Do you want a free e-mail for life ? Get it at http://www.email.ro/