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:
  #1  
Old July 26th, 2001, 04:59 AM
608zDcom 608zDcom is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: uk
Posts: 2 608zDcom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to 608zDcom
Question Perl query of a simple mysql databse

hello,


i need to query this table 'MODEMS' in my 'rota' database.

the format for 'MODEMS' is thus:



mysql> select * from MODEMS;
+-----+--------------------+
|Date | Name |
+-----+--------------------+
|01 | Darren Bristow |
|02 | Darren Bristow |
|03 | Darren Bristow |
+---------------------------+


I need to read the value of 'Name' into a perl variable, for printing, if '$date_query' = n.
Where n=todays date.


thanks,
Marcus

Reply With Quote
  #2  
Old July 26th, 2001, 05:03 AM
robert.swift's Avatar
robert.swift robert.swift is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Manchester, UK
Posts: 80 robert.swift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Marcus,

Are you asking for a shell script to process output from the mysql command or a perl script to handle the database itself?
__________________
Robert.

Reply With Quote
  #3  
Old July 26th, 2001, 05:06 AM
608zDcom 608zDcom is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: uk
Posts: 2 608zDcom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to 608zDcom
I'm looking to write it all in perl.

I need to query a mysql database using perl, reading the answer into a perl variable for manipulation.

Reply With Quote
  #4  
Old July 26th, 2001, 05:17 AM
robert.swift's Avatar
robert.swift robert.swift is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Manchester, UK
Posts: 80 robert.swift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
In that case, do you know the DBI or are you after the whole thing?

Suggest you search this board, check out CPAN for the DBI module and mysql.com for docs.

Reply With Quote
  #5  
Old July 26th, 2001, 05:21 AM
robert.swift's Avatar
robert.swift robert.swift is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Manchester, UK
Posts: 80 robert.swift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
try:

Code:
my $qs = "SELECT Name FROM MODEMS WHERE Date = $perldatevariable";
my $doselect = $dbh->prepare($qs);
$doselect->execute;
my $srows = $doselect->rows;
if ($srows > 0) {
  my ($name) = $doselect->fetchrow_array();
  print $name . " is selected for " . $perldatevariable;
}
$doselect->finish;

Reply With Quote
  #6  
Old July 26th, 2001, 10:53 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Check out the documentation for DBI.pm.
Code:
$ perldoc DBI

Most MySQL books have a starter section on using DBI as well. If you are looking for some more informative instruction on using DBI then I recommend Programming the Perl DBI by O'Reilly.
__________________
- dsb -
Perl Guy

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl query of a simple mysql databse


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 2 hosted by Hostway
Stay green...Green IT