Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Advice for perl newbie 2

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
0
0
US
Hi , I'm a student taking perl at the moment and my class doesn't cover databases so I want to go out on my own to learn it myself.

I have some server space that I purchased on the web and they are using MySQL. So I am looking for a good way to learn the connectivity and data manipulation of this type of database. Any links or reference books you can tell me about I would greatly appreciate it.

I have done some searching on the web and I found a Win32::ODBC module but wasn't sure if thats what I needed or if my web service even has this. Again any advice would be greatly appreciated.

Thanks, Rick
 
Check out the DBI package on CPAN. It's what I use and it's great.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Go spend $35 on 'Programming the Perl DBI' by Descarte and Bunce, published by O'Reilly. It goes over some basic SQL stuff ( the language you use to talk to a Database) and addresses connecting to and interacting with databases. Most of the examples use Oracle, but, the beauty of the DBI/DBD approach is that if you know how to connect to an Oracle instance, then you pretty much know how to connect to a MySQL instance.

HTH


keep the rudder amid ship and beware the odd typo
 
Thanks,for the info. I did see the DBI book at the store but wasn't sure that wouldhelp me, but now I know different. I will definately check out all the links as well.
 
I'm back with another question. My provider is using Mod_perl, does that include the DBI module? I called to ask them but the tech seemed like he didn't know what I was talking about.

Thanks,
Rick
 
That's not surprising. It's amazing how many ISP tech support people I've talked to are clueless about their setup.

mod_perl does not, so far as I know, inherently include DBI. My suggestion would be to try to include the lib and see what happens. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Well, I'm not getting off the ground very well. Here is my connection code:

$DSN= "dbi:mysql:$database";
my $dbh = DBI->connect($DSN,$user,$pass) || die print "$DBI::errstr\n";

and I get the error:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

Again I e-mailed my Tech support and again they didn't know squat.

It looks to like the DBI module is installed since its looking for the driver, am I correct in assuming this?

Any help would be appreciated.

Thanks!
 
To tell if the module is installed, just try to 'use' it. If it is not there, the 'use' will fail.

!#/usr/local/bin/perl
use DBI;
use CGI;
my $cgi = new CGI;
print $cgi->header,$cgi->start_html;
print &quot;<P>The 'use' worked'.</P>\n&quot;;
print $cgi->end_html;


If the 'use' works, then you should get you message. If it does not, then will see some sort of error.



HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top