Forum: Ruby Newbie in Ruby...Issues while connecting Ruby with Sqlite3

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Manish K. (Guest)
on 2008-12-02 06:06
Hi,

I am a newbie in Ruby. Its very interesting language. Now, my problem is
with the below code.

require 'rubygems'
require 'sqlite3'
db = SQLite3:atabase.new( "test2.db" )
db.execute("create table t1 (id INTEGER PRIMARY KEY,data TEXT,num
double,timeEnter DATE)")
db.execute( "insert into t1 (data,num) values ('This is sample
data',3)")
rows = db.execute( "select * from t1" )
end

I am receiving this error: "database.rb:7: syntax error, unexpected
kEND, expecting $end"

Please help.

I have installed the sqlite3 gem.

Please help. Thanks!
Michael L. (Guest)
on 2008-12-02 06:35
(Received via mailing list)
On Mon, Dec 1, 2008 at 10:01 PM, Manish Kalra
<removed_email_address@domain.invalid> wrote:
> db.execute( "insert into t1 (data,num) values ('This is sample
> data',3)")
> rows = db.execute( "select * from t1" )
> end
>
> I am receiving this error: "database.rb:7: syntax error, unexpected
> kEND, expecting $end"

This error message is telling you the filename, then the line number
where the error is to be found. It is also telling you that it's a
syntax error, and what kind of syntax error. In this case it found an
unexpected kEND (an END keyword), like the "end" on the last line of
your program. That "end" doesn't match any starting keyword (like
"if", "while", "begin", "def", or "class", to name a few), so it's a
problem. Just remove it. The program will end on its own.

If you need to ensure that the program exits, use Kernel.exit instead.

 -Michael L.
_-_ Daniel _-_ (Guest)
on 2008-12-02 09:11
(Received via mailing list)
On Mon, 01 Dec 2008 20:29:01 -0800, Michael L.
<removed_email_address@domain.invalid> wrote:

>> db.execute("create table t1 (id INTEGER PRIMARY KEY,data TEXT,num
> where the error is to be found. It is also telling you that it's a
> syntax error, and what kind of syntax error. In this case it found an
> unexpected kEND (an END keyword), like the "end" on the last line of
> your program. That "end" doesn't match any starting keyword (like
> "if", "while", "begin", "def", or "class", to name a few), so it's a
> problem. Just remove it. The program will end on its own.
>
> If you need to ensure that the program exits, use Kernel.exit instead.
>
>  -Michael L.
>

FYI: db = SQLite3:atabase.new( "test2.db" )

atabase.new ?
This topic is locked and can not be replied to.