<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: How to access MySQL database using Perl</title> <atom:link href="http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: UncaAlby</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-63912</link> <dc:creator>UncaAlby</dc:creator> <pubDate>Thu, 27 Oct 2011 07:14:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-63912</guid> <description>Works like a champ!
My only significant modifications were &quot;use strict&quot; which means adding &quot;my&quot; to declare all the variables.
It would be nice if it also had an example of adding parameters to the prepared statement. I happened to look that up separately, which I&#039;m adding to this comment in case someone else finds it useful.
Example: list every row where the user_id starts with &quot;a&quot;.
&lt;pre&gt;
$sql = &quot;select user_id from users where user_id like ?&quot;;
$sth = $dbh-&gt;prepare($sql) or die(DBI-&gt;errstr);
$sth-&gt;bind_param(1, &quot;a%&quot;);
$rv = $sth-&gt;execute or die(DBI-&gt;errstr);
print &quot;User ID&#039;s that start with &#039;a&#039;\n&quot;;
while (my @row = $sth-&gt;fetchrow_array()) {
my $tables = $row[0];
print &quot;$tables\n&quot;;
}
$rc = $sth-&gt;finish;
&lt;/pre&gt;
Results (from my table):
User ID&#039;s that start with &#039;a&#039;
&lt;pre&gt;admin
alameda
arthur&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>Works like a champ!</p><p>My only significant modifications were &#8220;use strict&#8221; which means adding &#8220;my&#8221; to declare all the variables.</p><p>It would be nice if it also had an example of adding parameters to the prepared statement. I happened to look that up separately, which I&#8217;m adding to this comment in case someone else finds it useful.</p><p>Example: list every row where the user_id starts with &#8220;a&#8221;.</p><pre>
$sql = "select user_id from users where user_id like ?";
$sth = $dbh-&gt;prepare($sql) or die(DBI-&gt;errstr);
$sth-&gt;bind_param(1, "a%");
$rv = $sth-&gt;execute or die(DBI-&gt;errstr);
print "User ID's that start with 'a'\n";
while (my @row = $sth-&gt;fetchrow_array()) {
  my $tables = $row[0];
  print "$tables\n";
}
$rc = $sth-&gt;finish;
</pre><p>Results (from my table):</p><p>User ID&#8217;s that start with &#8216;a&#8217;</p><pre>admin
alameda
arthur</pre>]]></content:encoded> </item> <item><title>By: ahmed</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-62859</link> <dc:creator>ahmed</dc:creator> <pubDate>Tue, 27 Sep 2011 08:48:56 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-62859</guid> <description>It&#039;s working very well
thank you.</description> <content:encoded><![CDATA[<p>It&#8217;s working very well<br
/> thank you.</p> ]]></content:encoded> </item> <item><title>By: Abby</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-51228</link> <dc:creator>Abby</dc:creator> <pubDate>Wed, 01 Dec 2010 07:34:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-51228</guid> <description>Works beautifully! Thank you :)</description> <content:encoded><![CDATA[<p>Works beautifully! Thank you :)</p> ]]></content:encoded> </item> <item><title>By: Lina</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-49961</link> <dc:creator>Lina</dc:creator> <pubDate>Wed, 06 Oct 2010 23:33:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-49961</guid> <description>This really does work.  After 3 days of searching this is the first script that works.
THANK YOU!!!!!!!</description> <content:encoded><![CDATA[<p>This really does work.  After 3 days of searching this is the first script that works.</p><p>THANK YOU!!!!!!!</p> ]]></content:encoded> </item> <item><title>By: Anitha</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-44990</link> <dc:creator>Anitha</dc:creator> <pubDate>Thu, 03 Dec 2009 05:15:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-44990</guid> <description>I have to synchronize bugzilla which uses  mysql and HP quality centre which uses  mssql .. i&#039;m tryin to do this in perl.. As a fresher i&#039;m not sure wat perl can do .. can anyone suggest me</description> <content:encoded><![CDATA[<p>I have to synchronize bugzilla which uses  mysql and HP quality centre which uses  mssql .. i&#8217;m tryin to do this in perl.. As a fresher i&#8217;m not sure wat perl can do .. can anyone suggest me</p> ]]></content:encoded> </item> <item><title>By: medoix</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-44790</link> <dc:creator>medoix</dc:creator> <pubDate>Fri, 20 Nov 2009 07:33:03 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-44790</guid> <description>Stone
remove $rv = and $rc = they are not needed on those lines.</description> <content:encoded><![CDATA[<p>Stone</p><p>remove $rv = and $rc = they are not needed on those lines.</p> ]]></content:encoded> </item> <item><title>By: Stone Man</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-40677</link> <dc:creator>Stone Man</dc:creator> <pubDate>Tue, 10 Mar 2009 04:48:11 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-40677</guid> <description>Hi Nixcraft,
Thanks for this code but i got the following:
- I copy the code and paste it in this file checkdb.sh.
- And run chmod +x checkdb.sh
- Then run ./checkdb.sh
Then the following occured:
Name &quot;main::rv&quot; used only once: possible typo at /usr/bin/check.db line 25.
Name &quot;main::rc&quot; used only once: possible typo at /usr/bin/check.db line 42.
Content-type: text/html
********** My Perl DBI Test ***************
Here is a list of tables in the MySQL database mysql.
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
[root@drbl-01 ~]#
Currently installed Perl Modules:
[root@drbl-01 DBD-mysql-4.010]# instmodsh
Available commands are:
l            - List all installed modules
m    - Select a module
q            - Quit the program
cmd? l
Installed modules are:
DBD::mysql
DBI
Perl
cmd? q
ANy suggestion on how to fix this?
Thanks again!
Stone</description> <content:encoded><![CDATA[<p>Hi Nixcraft,</p><p>Thanks for this code but i got the following:</p><p>- I copy the code and paste it in this file checkdb.sh.<br
/> - And run chmod +x checkdb.sh<br
/> - Then run ./checkdb.sh</p><p>Then the following occured:</p><p>Name &#8220;main::rv&#8221; used only once: possible typo at /usr/bin/check.db line 25.<br
/> Name &#8220;main::rc&#8221; used only once: possible typo at /usr/bin/check.db line 42.<br
/> Content-type: text/html</p><p>********** My Perl DBI Test ***************</p><p>Here is a list of tables in the MySQL database mysql.</p><p>columns_priv<br
/> db<br
/> event<br
/> func<br
/> general_log<br
/> help_category<br
/> help_keyword<br
/> help_relation<br
/> help_topic<br
/> host<br
/> ndb_binlog_index<br
/> plugin<br
/> proc<br
/> procs_priv<br
/> servers<br
/> slow_log<br
/> tables_priv<br
/> time_zone<br
/> time_zone_leap_second<br
/> time_zone_name<br
/> time_zone_transition<br
/> time_zone_transition_type<br
/> user<br
/> [root@drbl-01 ~]#</p><p>Currently installed Perl Modules:</p><p>[root@drbl-01 DBD-mysql-4.010]# instmodsh<br
/> Available commands are:<br
/> l            &#8211; List all installed modules<br
/> m    &#8211; Select a module<br
/> q            &#8211; Quit the program<br
/> cmd? l<br
/> Installed modules are:<br
/> DBD::mysql<br
/> DBI<br
/> Perl<br
/> cmd? q</p><p>ANy suggestion on how to fix this?<br
/> Thanks again!</p><p>Stone</p> ]]></content:encoded> </item> <item><title>By: Ron Lusk</title><link>http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-38814</link> <dc:creator>Ron Lusk</dc:creator> <pubDate>Fri, 19 Sep 2008 21:59:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/how-to-access-mysql-database-using-perl/#comment-38814</guid> <description>I&#039;ve looked at a lot of sample code trying to learn how to successfully get extract &lt;b&gt;any&lt;/b&gt; information from a database and this has been the first that actually worked! Kudos. Very helpful.</description> <content:encoded><![CDATA[<p>I&#8217;ve looked at a lot of sample code trying to learn how to successfully get extract <b>any</b> information from a database and this has been the first that actually worked! Kudos. Very helpful.</p> ]]></content:encoded> </item> </channel> </rss>
