Check data in mysql


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check data in mysql
# 1  
Old 05-04-2014
Check data in mysql

Hi, I just would like to write a perl script , this perl script do the following .

Check the parameter $data in a mysql database ( with user ID and password ) , if the $data is exist then return true , if not then return false , would advise how to write this script ? thanks

---------- Post updated 05-04-14 at 06:29 AM ---------- Previous update was 05-03-14 at 09:01 PM ----------

I have the below perl script to connect the mysql db , would advise how to change it to check if the parameter $data is exist in mysql database or not , then return true or false ? thanks
Code:
use DBI
use strict;
my $driver = "mysql"; 
my $database = "TESTDB";
my $dsn = "DBI:$driver:database=$database";
my $userid = "testuser";
my $password = "test123";
my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr;


Last edited by Franklin52; 05-04-2014 at 10:39 AM.. Reason: Please use code tags
# 2  
Old 05-05-2014
This is an example(in addition to what you already have done) to access a table in a mysql database:
How to Use Perl to Connect to a Database « Perl
How to Connect to MySQL from Perl and Select Records with Example
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send Data to MySQL Table Columns

I have two scripts, each script reads an individual data file and copies specific lines of data and sends to MySQL table. Only difference is, each script sends data to a separate column on the same DB. I want to use one script to populate DB table and have data look horizontal, with no overlapping.... (3 Replies)
Discussion started by: SysAdminRialto
3 Replies

2. Programming

Need help on Insert data to mySQL database

Hi guys, I would like to seek help on inserting data whenever the switch is on or off to my sensor mySQL database in phpMyAdmin from my control.php. I'm using Raspberry PI as my hardware and follow a few tutorials to create my own Web Control Interface, it works perfectly without insert method.... (1 Reply)
Discussion started by: aoiregion
1 Replies

3. Shell Programming and Scripting

Need help with extracting data to MySQL format

Hi guys, I'm doing a project now and extracting tables from a webpage to MySQL table format. I dumped the webpage with lynx and it is like this id Spec 524543 Developed especially for seniors Spec No Java Spec Yes Java MIDP Spec ... (4 Replies)
Discussion started by: Johanni
4 Replies

4. Infrastructure Monitoring

moving rrd data to mysql

All I currently run an application called OpenNMS. This is a free enterprise grade NMS. Its current framework uses RRDs to collect performance/node level data such as cpu load via snmp. all data is stored in these RRDs. I was wondering if anyone out there has had a chance or a need to move the... (2 Replies)
Discussion started by: pupp
2 Replies

5. Shell Programming and Scripting

sh and MySQL LOAD DATA

I have a csv file in a folder that is roughly 500,000 rows long. Rather than using PHP, I would like to use SH to run a MYSQL LOAD DATA command to load the data in, as I think it would be much faster and would not cause any memory problems associated with PHP. But the problem is, I am not... (18 Replies)
Discussion started by: worchyld
18 Replies

6. Shell Programming and Scripting

Help Inserting data in mysql table

Cant understand the error #!/bin/bash temp="" A="" D=$(date +"%Y-%m-%d") H=$(date +"%R") temp=$(wget -q -O - website | grep -o "Temperature:]**" | grep \-E -o "+") mysql -D "weather_wise" -e "INSERT INTO weather (Date, Hour, Degrees) VALUES ($D,$H, $temp)"; my data types for... (11 Replies)
Discussion started by: vadharah
11 Replies
Login or Register to Ask a Question