Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 27th, 2000, 05:41 PM
bydavid bydavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: USA
Posts: 67 bydavid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
hello

i am trying to use DBI to connect to a mysql database.

i used this

$DSN="DBI:mysql:database";
$db=DBI->connect($DSN,"user","pass");

but i could not connect.

so i used the funciton DBI->available_drivers() and found that the MySQL driver did not show up.

is this why i could not connect? how do i get the driver onto the server? how can i get this to work?

thanks in advance for reading my post.

-david

Reply With Quote
  #2  
Old July 27th, 2000, 06:38 PM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
You go to CPAN and search for MySQL DBD DBI driver. Once you get it, simply follow the instructions inside the tarball and you'll soon get it installed. Its really no big deal...

HTH

Reply With Quote
  #3  
Old July 28th, 2000, 07:38 AM
christucker
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
David,

Go to a command line and type:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>perl -MCPAN -e shell[/code]

This will take you into an interactive "shell" to download and install CPAN modules.
At the command prompt you're given, type:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>install DBD::mysql[/code]

The shell will now go out and grab all the appropriate modules and install them for you. Note, if you haven't used the CPAN shell before, you'll be asked a few configuration questions -- ignore the ones you don't understand, and fill in the others. The beauty of the CPAN shell is that it generally goes out and finds all of the dependancies you may need for a module to run, and will grab and build those too, thereby simplifying the whole process.

One note, you may (for some modules) need a C compiler and make program. If you're on Wintel, your easiest option is MS Visual Studio, though there are various ports of the GNU tools kicking around that may work (check out cygwin.com). Naturally, on un*x systems you should have a full set of tools avaiable from GNU or your favourite proprietary vendor.

[This message has been edited by christucker (edited July 29, 2000).]

Reply With Quote
  #4  
Old July 29th, 2000, 06:58 PM
bydavid bydavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: USA
Posts: 67 bydavid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
thakns for all the information, im going to try it out. btw, how is DBD used?


-thanks

Reply With Quote
  #5  
Old July 29th, 2000, 07:49 PM
christucker
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The DBD is specified in your connect string to the database. It's completely transparent so long as you stick to 'ordinary' (i.e. relatively standardised) SQL (any of your standard SELECT, INSERT, UPDATE, etc. stuff, basically, and most ALTER, CREATE etc.). The DBD (that's DataBase Driver, by the way) is simply an interface between the abstract DBI (DataBase Interface) layer, and the database itself. So, using MySQL, all you need to know about the DBD is that its name is mysql, and so your DBI connect call will be something like:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
my $dbh = DBI->connect('DBI:mysql:mydatabase', $user, $pass, $extra_options);
[/code]
Most of the time $extra_options won't be used -- if you do need it, it's just a reference to a hash of options like RaiseError. There's loads of info on that in the DBI PODs.

Reply With Quote
  #6  
Old July 30th, 2000, 09:36 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
That's what I like about it. If you want to move your script from MySQL to, say, ODBC, you just have to change that 1 line of code. Most of the time, anyway...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > using perl DBI


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway