10 Replies - 953 Views - Last Post: 26 January 2014 - 06:31 PM Rate Topic: -----

#1 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 01:11 PM


require 'sqlite3'

while true do
print "Enter the NAME: "
name = gets.chomp

print "Enter the ADDRESS: "
add = gets.chomp

print "Enter the SEX: "
sex = gets.chomp




begin
    
    db = SQLite3::Database.open "test.db"

    db.execute "INSERT INTO people(name,address,sex) VALUES(#{name},#{add},#{sex})"
   
    
rescue SQLite3::Exception => e 
    
    puts "Exception occured"
    puts e
    
ensure
    db.close if db
end
end


I get an error that says NO SUCH TABLE :people even theres a tables. I tried it in different tables and it`s not working also?

Is This A Good Question/Topic? 0
  • +

Replies To: Weird error. NO SUCH TABLE even there is.

#2 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1377
  • View blog
  • Posts: 3,501
  • Joined: 28-November 09

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 01:32 PM

This is time for a valuable lesson called reading the manual. Five seconds into Google and I've found this: https://github.com/s...on/sqlite3-ruby

...and on the third code line of the synopsis in the readme, we find it making a new database. If you look at your error, it's probably on line 18. You're trying to open something that doesn't exist, and as such you need to make a new database.

Now I will clear this up once, we're not after you for being new. We're after you for not doing due diligence in finding out how to do things. In the previous topic we mentioned the 'Give me code' bit not as a literal, but as a you need to do the legwork. Spoonfeeding you everything will do no good, and you won't grow as a developer if you get treated like that.

Do note that treating Ruby like PHP is going to bring some serious pain. What are you ultimately trying to achieve here?

That being said, Sequel should be your best friend: http://sequel.jeremyevans.net/

Object Relational Mappers, very useful. While it is good to know SQL, most of the time you really don't need to even bother.
Was This Post Helpful? 1
  • +
  • -

#3 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 03:06 PM

View PostLemur, on 26 January 2014 - 01:32 PM, said:

...and on the third code line of the synopsis in the readme, we find it making a new database. If you look at your error, it's probably on line 18. You're trying to open something that doesn't exist, and as such you need to make a new database.



Even I created the database "test" I will create it again?
Was This Post Helpful? 0
  • +
  • -

#4 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1377
  • View blog
  • Posts: 3,501
  • Joined: 28-November 09

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 05:29 PM

Depends on what you mean by it was created.

Really though, what's your end game here and what do you want to use this for? We could probably be of more help with a bigger picture.
Was This Post Helpful? 0
  • +
  • -

#5 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 05:50 PM

I just want to add records edit and delete. A simple program for ruby. But I find it hard to connect from a database. Is it possible in a notepad?
Was This Post Helpful? 0
  • +
  • -

#6 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1377
  • View blog
  • Posts: 3,501
  • Joined: 28-November 09

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 05:59 PM

View Postboulde4rmash, on 26 January 2014 - 06:50 PM, said:

I just want to add records edit and delete. A simple program for ruby. But I find it hard to connect from a database. Is it possible in a notepad?


What now? Clarify that a bit.
Was This Post Helpful? 0
  • +
  • -

#7 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 06:05 PM

View PostLemur, on 26 January 2014 - 05:59 PM, said:

View Postboulde4rmash, on 26 January 2014 - 06:50 PM, said:

I just want to add records edit and delete. A simple program for ruby. But I find it hard to connect from a database. Is it possible in a notepad?


What now? Clarify that a bit.



I'm sorry but I don`t have much time to learn how to work databases in ruby, I'm in a bit hurry, I think File or notepad will be a bit faster to do?
Was This Post Helpful? 0
  • +
  • -

#8 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1377
  • View blog
  • Posts: 3,501
  • Joined: 28-November 09

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 06:08 PM

If you don't have the time to do it right in the first place, you won't have the time to fix it later.

You're still not really explaining what you mean. Sqlite3 is file based if that's what you're referring to, but as I said in the other topic you're on a fools errand to try and get that up and running on Windows.
Was This Post Helpful? 0
  • +
  • -

#9 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 06:21 PM

I have to do a add edit delete search program for ruby. But I dont have any knowlodge with this. My time has been eaten how to configure mysql connect to ruby for windows but it didnt work. So I try the sq lite because its gem successfully intalled in my pc.
Was This Post Helpful? 0
  • +
  • -

#10 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1377
  • View blog
  • Posts: 3,501
  • Joined: 28-November 09

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 06:28 PM

1. https://www.virtualbox.org/
2. http://www.linuxmint.com/
3. http://sequel.jeremyevans.net/

Download 1 & 2, and get 3 running. Sequel's site explains just about everything you would ever want to know.
Was This Post Helpful? 1
  • +
  • -

#11 boulde4rmash  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 65
  • Joined: 29-September 11

Re: Weird error. NO SUCH TABLE even there is.

Posted 26 January 2014 - 06:31 PM

Thanks sir, gonna check that when i got home :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1