From: Robert Klemme Date: 2013-06-22T21:38:46+09:00 Subject: Re: DB transaction setup, and feeling stupid. --047d7bf0f4a075a18b04dfbd7427 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jun 22, 2013 at 1:26 AM, Mike Stok wrote: > > On 2013-06-21, at 7:20 PM, "Ken D'Ambrosio" wrote: > > Hi, all. I'm a relative Ruby newb, and I'm trying to set up paramaterized > MySQL queries. And am getting completely stumped. I do a similar query > slightly before this one, and it works great. This one? Not so much. It > fails with the same error in my .rb file, but I figured I'd give the pry > for the gory details (and fewer lines): > > [1] pry(main)> require 'mysql' > => true > [2] pry(main)> @db_conn = Mysql.new 'localhost', 'root', 'passwordhere', > 'jabberlogs' > => # > [3] pry(main)> line = '/home/ken/.purple/logs/jabber/kdambr200@cable > /aabreh200@vss-xmpp.sys.comcast.net/2013-04-10.100100-0400EDT.html' > => "/home/ken/.purple/logs/jabber/kdambr200@cable/ > aabreh200@vss-xmpp.sys.comcast.net/2013-04-10.100100-0400EDT.html" > [4] pry(main)> @dbio = @db_conn.prepare "SELECT file_id FROM loglines > WHERE line=\"?\"" > > > Have you tried > > @dbio = @db_conn.prepare "SELECT file_id FROM loglines WHERE line=?" > > So that the place holder is not "hidden" in a string? > It's not hidden - it's not a placeholder any more. :-) I agree: I am almost 100% sure that this is the issue. When looking at the error message it mentions 0 parameters but found 1 argument (see below). > > => # > [5] pry(main)> @dbio.execute(line) > Mysql::Error: execute: param_count(0) != number of argument(1) > from (pry):5:in `execute' > > Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --047d7bf0f4a075a18b04dfbd7427 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Sat, Jun 22, 2013 at 1:26 AM, Mike Stok <mike@stok.ca>= wrote:

On 2013-06-21, at 7:20 PM, "Ken D'Ambrosio" <= ;ken@jots.org> wro= te:

Hi, all. =A0I'm a relative Ruby newb, and= I'm trying to set up paramaterized MySQL queries. =A0And am=A0getting = completely stumped. =A0I do a similar query slightly before this one, and i= t works great. =A0This=A0one? =A0Not so much. =A0It fails with the same err= or in my .rb file, but I figured I'd give the pry for the=A0gory detail= s (and fewer lines):

[1] pry(main)> require 'mysql'
=3D> true
[2] pry(ma= in)> @db_conn =3D Mysql.new 'localhost', 'root', 'pa= sswordhere', 'jabberlogs'
=3D> #<Mysql:0x0000000183f76= 0>
[3] pry(main)> line =3D '/home/ken/.purple/logs/jabber/kdambr200@cab= le/aabreh200@vss-xmpp.sys.comcast.net/2013-04-10.100100-= 0400EDT.html'
=3D> "/home/ken/.purple/logs/jabber/kdambr200@cable/aabreh200@vss-xmpp.sys.comcast.net/2013-04-10.100100-0400EDT.h= tml"
[4] pry(main)>=A0@dbio =3D @db_conn.prepare "SELECT file_id FROM lo= glines WHERE line=3D\"?\""

= Have you tried

@dbio =3D @db_conn.prepare "SELECT f= ile_id FROM loglines WHERE line=3D?"

So that the place holder is not "hidden" in a= string?

It's not hidden - = it's not a placeholder any more. :-) =A0I agree: I am almost 100% sure = that this is the issue. =A0When looking at the error message it mentions 0 = parameters but found 1 argument (see below).
=A0

=3D> #<Mys= ql::Stmt:0x00000001599a60>
[5] pry(main)> @dbio.execute(line)
Mysql::Error: execute: param_count= (0) !=3D number of argument(1)
from (pry):5:in `execute'
Kind regards

robert

--
remember.guy do |as, often| as.you_c= an - without end
http://b= log.rubybestpractices.com/
--047d7bf0f4a075a18b04dfbd7427--