|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Problem in connecting to db through perl
hello,
I am a newbie on the block... I am trying to connect to to postgres through a perl script. tried doing the following stuff... $dbh = DBI->connect('DBI:Pg:dbname=mydb', 'postgres', 'postgres'); if ($dbh) { print "connected\n"; print "b4 prepare..\n"; $sth = $dbh->prepare("select * from mytable"); print "sth is: $sth\n"; $sth->execute(); print "after execute.. sth: $sth\n"; the problem is that when i try to connect to the mydb through this script it takes the default user to be root and not postgres. the script runs on 777 and is owned by root, so tried runnig it as: su -c 'perl testscript.pl' postgres but it gives the following errors: bash: /root/.bashrc: Permission denied DBI connect('dbname=postgres','postgres',...) failed: FATAL 1: Database "postgres" does not exist in the system catalog. at testscript.pl line 30 Cannot connect to Postgres server: FATAL 1: Database "postgres" does not exist in the system catalog. db connection failed and this is the case if the db is owned by any other user than root, in this case the owner of mydb is postgres but it doesnt seem to access the db.. but when the onwer of the db is root thenn it seems to be working... I am confused as to where the problem lies..is it with the scripts,the permission or missing out on what.. not able to figure it out.. ne help on this would be a honour..[ ]thanku |
|
#2
|
||||
|
||||
|
To me it looks like you're missing some parameters in the connection string. Take a look at this link and give it a try.
I'm not that familiar with Perl, sorry.
__________________
PostgreSQL-manual |
|
#3
|
|||
|
|||
|
hey thanks for that prompt help.. i was messing up the synatx
thanku once again.[ ] |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > Problem in connecting to db through perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|