librelist archives

« back to archive

sqlite3 with ruby returning nothing

sqlite3 with ruby returning nothing

From:
Luka Povreslo
Date:
2015-02-15 @ 14:29
I created sqlite3 table manually with 3 values like this:
data.db
CREATE TABLE subjects (title TEXT, content TEXT);

and here's my ruby/shoes code:

require 'sqlite3'

Shoes.app do
      $db = SQLite3::Database.open('data.db')
     @edit_l = edit_line
     @edit_b = edit_box
     button "Save" do
         $db.execute("insert into subjects values(?, ?), [@edit_l.text,
@edit_b.text])           #these values get saved and it looks just fine
     end

end

Problem is when I want to acces my data either from cmd or from shoes, I
get nothing as a result

for example this code gives nothing as a result-
 "select title from subjects where content = "some value";
Where "some value" is existing database value.

I think the problem is with saving values from shoes/ruby, probably I need
to convert it in some other way that I'm not sure how to perform.


-- 
*Cheers!*

Re: [shoes] sqlite3 with ruby returning nothing

From:
Cecil Coupe
Date:
2015-02-15 @ 21:23
I don't use sql myself because I get confused by the substitutions and 
syntax. However, samples/simple-sqlite would suggest you want

On 02/15/2015 07:29 AM, Luka Povreslo wrote:
>          $db.execute("insert into subjects values(?, ?), 
> [@edit_l.text, @edit_b.text]) #these values get saved and it looks 
$db.execute("insert into subjects (title, contents) values 
(#{@edit_l.text}, #{@edit_b.text})"

--Cecil