# Trouble with sqlite-ruby

**URL:** <https://rubytalk.org/t/trouble-with-sqlite-ruby/19074>\
**Category:** ruby-talk\
**Created:** [20 June 2005 07:10 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074 "2005-06-20T07:10:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lowell\_Kirsh](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Lowell\_Kirsh](https://rubytalk.org/u/Lowell_Kirsh)\
**Post date:** [20 June 2005 07:10 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/1 "2005-06-20T07:10:35Z")

</div>

I'm having trouble getting bind parameters to work. I'm getting errors along the line of "no such bind parameter 'file' (SQLite3::Exception)". This arises in 2 situations, which are probably both doing the same thing under the hood. Here are the pices of code that give me the errors:

&nbsp;&nbsp;&nbsp;stmt = db.prepare("select \* from mp3 where file = :file;")  
&nbsp;&nbsp;&nbsp;stmt.bind\_param('file', 'hello')  
and

&nbsp;&nbsp;&nbsp;stmt = db.execute("select \* from mp3 where file = :file;",  
&nbsp;&nbsp;&nbsp;"file" =\> 'hello')

I don't know why Ruby thinks there is no such bind parameter as 'file' when it's clearly there in the string.

Lowell

---

<div class="post-metadata">

**Author:** ![Jaypee1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@Jaypee1](https://rubytalk.org/u/Jaypee1)\
**Post date:** [20 June 2005 19:25 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/2 "2005-06-20T19:25:35Z")

</div>

Lowell Kirsh a écrit :

> I'm having trouble getting bind parameters to work. I'm getting errors along the line of "no such bind parameter 'file' (SQLite3::Exception)". This arises in 2 situations, which are probably both doing the same thing under the hood. Here are the pices of code that give me the errors:
> 
> &nbsp;&nbsp;stmt = db.prepare("select \* from mp3 where file = :file;")  
> &nbsp;&nbsp;stmt.bind\_param('file', 'hello')  
> and
> 
> &nbsp;&nbsp;stmt = db.execute("select \* from mp3 where file = :file;",  
> &nbsp;&nbsp;"file" =\> 'hello')
> 
> I don't know why Ruby thinks there is no such bind parameter as 'file' when it's clearly there in the string.
> 
> Lowell

My little, tiny experience with SQLite3 is that it requires quote around  
the tables and columns name. Have you tried this way:  
stmt = db.prepare("select \* from 'mp3' where 'file' = :file;")  
J-P

---

<div class="post-metadata">

**Author:** ![Gyoung-Yoon\_Noh1](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gyoung-Yoon\_Noh1](https://rubytalk.org/u/Gyoung-Yoon_Noh1)\
**Post date:** [20 June 2005 19:41 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/3 "2005-06-20T19:41:36Z")

</div>

It seems to be recognized as one token ':file;', not ':file' as you expected.  
Omit semicolon(;), indeed, semicolon need not be there  
.

> **···**
>
> On 6/20/05, Lowell Kirsh \<lkirsh@cs.ubc.ca\> wrote:
> 
> > I'm having trouble getting bind parameters to work. I'm getting errors  
> > along the line of "no such bind parameter 'file' (SQLite3::Exception)".  
> > This arises in 2 situations, which are probably both doing the same  
> > thing under the hood. Here are the pices of code that give me the errors:
> > 
> > &nbsp;&nbsp;&nbsp;stmt = db.prepare("select \* from mp3 where file = :file;")  
> > &nbsp;&nbsp;&nbsp;stmt.bind\_param('file', 'hello')  
> > and
> > 
> > &nbsp;&nbsp;&nbsp;stmt = db.execute("select \* from mp3 where file = :file;",  
> > &nbsp;&nbsp;&nbsp;"file" =\> 'hello')
> > 
> > I don't know why Ruby thinks there is no such bind parameter as 'file'  
> > when it's clearly there in the string.
> > 
> > Lowell
> 
> --  
> [http://nohmad.sub-port.net](http://nohmad.sub-port.net)

---

<div class="post-metadata">

**Author:** ![Lowell\_Kirsh](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Lowell\_Kirsh](https://rubytalk.org/u/Lowell_Kirsh)\
**Post date:** [20 June 2005 20:55 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/4 "2005-06-20T20:55:36Z")

</div>

Jaypee wrote:

> My little, tiny experience with SQLite3 is that it requires quote around  
> the tables and columns name. Have you tried this way:  
> stmt = db.prepare("select \* from 'mp3' where 'file' = :file;")  
> J-P

Thanks, but I tried that and I'm still getting the same error. Any other ideas?

---

<div class="post-metadata">

**Author:** ![Lowell\_Kirsh](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Lowell\_Kirsh](https://rubytalk.org/u/Lowell_Kirsh)\
**Post date:** [20 June 2005 21:00 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/5 "2005-06-20T21:00:35Z")

</div>

Gyoung-Yoon Noh wrote:

> It seems to be recognized as one token ':file;', not ':file' as you expected.  
> Omit semicolon(;), indeed, semicolon need not be there

I removed the semicolon but I still get the same error. Any other ideas? After a couple of hours of trying to figure this out, it's starting to look like a bug in sqlite-ruby to me.

---

<div class="post-metadata">

**Author:** ![Jamis\_Buck2](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Jamis\_Buck2](https://rubytalk.org/u/Jamis_Buck2)\
**Post date:** [20 June 2005 21:09 UTC](https://rubytalk.org/t/trouble-with-sqlite-ruby/19074/6 "2005-06-20T21:09:22Z")

</div>

Yup, it's a bug. I can duplicate it, and I've got a failing test case for it now, but I don't know \_why\_ it is failing, and I probably won't have time to dig in and investigate it for a while. If anyone manages to come up with a patch for this, I'd be very grateful.

- Jamis

> **···**
>
> On Jun 20, 2005, at 3:00 PM, Lowell Kirsh wrote:
> 
> > Gyoung-Yoon Noh wrote:
> > 
> > > It seems to be recognized as one token ':file;', not ':file' as you expected.  
> > > Omit semicolon(;), indeed, semicolon need not be there
> > 
> > I removed the semicolon but I still get the same error. Any other ideas? After a couple of hours of trying to figure this out, it's starting to look like a bug in sqlite-ruby to me.
