From: Mike Stok Date: 2013-06-22T08:26:51+09:00 Subject: Re: DB transaction setup, and feeling stupid. --Apple-Mail=_9ECE9C6B-E967-47B9-9178-DDB76D235619 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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): >=20 > [1] pry(main)> require 'mysql' > =3D> true > [2] pry(main)> @db_conn =3D Mysql.new 'localhost', 'root', = 'passwordhere', 'jabberlogs' > =3D> # > [3] pry(main)> line =3D = '/home/ken/.purple/logs/jabber/kdambr200@cable/aabreh200@vss-xmpp.sys.comc= ast.net/2013-04-10.100100-0400EDT.html' > =3D> = "/home/ken/.purple/logs/jabber/kdambr200@cable/aabreh200@vss-xmpp.sys.comc= ast.net/2013-04-10.100100-0400EDT.html" > [4] pry(main)> @dbio =3D @db_conn.prepare "SELECT file_id FROM = loglines WHERE line=3D\"?\"" Have you tried @dbio =3D @db_conn.prepare "SELECT file_id FROM loglines WHERE line=3D?" So that the place holder is not "hidden" in a string? > =3D> # > [5] pry(main)> @dbio.execute(line) > Mysql::Error: execute: param_count(0) !=3D number of argument(1) > from (pry):5:in `execute' >=20 > I've tried all the permutations I can think for syntax surrounding the = question mark... but I'm kinda stumped. Any pointers? >=20 > Thanks kindly, >=20 > -Ken Hope this helps, Mike --=20 Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. --Apple-Mail=_9ECE9C6B-E967-47B9-9178-DDB76D235619 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
On 2013-06-21, at 7:20 PM, = "Ken D'Ambrosio" <ken@jots.org> = 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'
=3D> true
[2] = pry(main)> @db_conn =3D Mysql.new 'localhost', 'root', = 'passwordhere', 'jabberlogs'
=3D> = #<Mysql:0x0000000183f760>
[3] pry(main)> line =3D = '/home/ken/.purple/logs/jabber/kdambr200@cable/aabreh200@vss-xmpp.= sys.comcast.net/2013-04-10.100100-0400EDT.html'
=3D> = "/home/ken/.purple/logs/jabber/kdambr200@cable/aabreh200@vss-xmpp.sys.comc= ast.net/2013-04-10.100100-0400EDT.html"
[4] pry(main)> @dbio = =3D @db_conn.prepare "SELECT file_id FROM loglines WHERE = line=3D\"?\""

Have you = tried

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

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

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

I've tried all the permutations I can think for syntax = surrounding the question mark... but I'm kinda stumped.  Any = pointers?

Thanks = kindly,

-Ken

Hope this = helps,

Mike

-- 

Mi= ke Stok <mike@stok.ca>
http://www.stok.ca/~mike/

Th= e "`Stok' disclaimers" = apply.






= --Apple-Mail=_9ECE9C6B-E967-47B9-9178-DDB76D235619--