|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ![]() |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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. ![]() |
|
#5
|
||||
|
||||
|
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;
|
|
#6
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl query of a simple mysql databse |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|