LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-02-2014, 07:52 PM   #1
derekchung_8080
LQ Newbie
 
Registered: May 2014
Location: ff
Posts: 5

Rep: Reputation: Disabled
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
 
Old 05-02-2014, 11:16 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Ask your instructor . . .
 
Old 05-04-2014, 06:03 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
There is a client program by name mysql, exactly for uses like this. (Perl is not required, shell in enough.)
http://www.freebsd.org/cgi/man.cgi?q...lt&format=html
 
Old 05-04-2014, 06:33 AM   #4
derekchung_8080
LQ Newbie
 
Registered: May 2014
Location: ff
Posts: 5

Original Poster
Rep: Reputation: Disabled
I have the below perl script to connect the mysql db , would advise how to make it to check if the parameter $data is exist or not , then return true or false ? thansk

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;
 
Old 05-04-2014, 07:15 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
C'mon, you got that much from the CPAN page for DBI, or its easy equivalent. Ask your instructor to show you how to write a SELECT query and to see if it returns any results. Ask about COUNT(*).

Or, switch majors in college now. Switch to an art class and stop trying to ask the world to help you cheat on your homework. Because, it only goes downhill from here. Computer programming does not consist of "learning enough about brake-pedals and steering wheels to successfully pilot a (say, Perl) motor-car around the block without crashing into a tree." No, it fundamentally consists of planning and then carrying-out a trip across the country, using whatever your car-of-choice (or of necessity ...) can do for you.

If you don't know what to do, and it appears right now that you do not, then it is fruitless for someone else to present to you a pretty packaged "answer" that actually does it ... because you will have learned nothing and will still know nothing of how to make a similar plan for yourself, to solve the next problem and the next and the next.

I'm not making fun of you: I'm telling you why you need to engage your instructor for help. Some of the time, I am an instructor.

I swear to you that I do not like to fill-in the little bubble on the opscan sheet that has an "F" in it, but I promise you also that I can always see it coming.

Last edited by sundialsvcs; 05-04-2014 at 07:18 AM.
 
Old 05-04-2014, 10:29 AM   #6
derekchung_8080
LQ Newbie
 
Registered: May 2014
Location: ff
Posts: 5

Original Poster
Rep: Reputation: Disabled
thanks reply ,

would advise how to chnage the above script ? thanks
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check data and run script ust Linux - Newbie 2 11-02-2012 01:09 PM
[SOLVED] Data Transfer With CRC Check spwnt Linux - Software 4 06-21-2011 03:49 PM
Perl .check if data are exist in the array before adding new data ufmale Programming 12 07-14-2010 05:26 AM
How can I get data out of MySQL if I can access the HD, but not run MySQL DJOtaku Linux - Server 4 01-11-2009 07:30 PM
Processing data from a 'foreign' database with mysql, or tools to pre-process data. linker3000 Linux - Software 1 08-14-2007 08:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration