# Newbie in Ruby...Issues while connecting Ruby with Sqlite3

**URL:** <https://www.ruby-forum.com/t/newbie-in-ruby-issues-while-connecting-ruby-with-sqlite3/154613>\
**Category:** Ruby\
**Created:** [December 2, 2008, 5:06am UTC](https://www.ruby-forum.com/t/newbie-in-ruby-issues-while-connecting-ruby-with-sqlite3/154613 "2008-12-02T05:06:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![graphicmist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c0e974/32.png) [@graphicmist](https://www.ruby-forum.com/u/graphicmist)\
**Post date:** [December 2, 2008, 5:06am UTC](https://www.ruby-forum.com/t/newbie-in-ruby-issues-while-connecting-ruby-with-sqlite3/154613/1 "2008-12-02T05:06:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![graphicmist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c0e974/32.png) [@graphicmist](https://www.ruby-forum.com/u/graphicmist)\
**Post date:** [December 2, 2008, 5:35am UTC](https://www.ruby-forum.com/t/newbie-in-ruby-issues-while-connecting-ruby-with-sqlite3/154613/2 "2008-12-02T05:35:23Z")

</div>

On Mon, Dec 1, 2008 at 10:01 PM, Manish Kalra  
[removed\_email\_address@domain.invalid](mailto: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.

---

<div class="post-metadata">

**Author:** ![graphicmist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c0e974/32.png) [@graphicmist](https://www.ruby-forum.com/u/graphicmist)\
**Post date:** [December 2, 2008, 8:11am UTC](https://www.ruby-forum.com/t/newbie-in-ruby-issues-while-connecting-ruby-with-sqlite3/154613/3 "2008-12-02T08:11:04Z")

</div>

On Mon, 01 Dec 2008 20:29:01 -0800, Michael L.  
[removed\_email\_address@domain.invalid](mailto: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 ?
