Kirbybase problem

T

Tom Cloyd

Jamey,

After a very long wait, I'm finally diving into the Kirbybase gem.

My problem is that I'm trying to create a table, following very
carefully the example given in the quite nice documentation (!), and
it's not working for me, and I cannot see the problem. The code
(stripped to essentials):

def main

%w(rubygems logger kirbybase yaml).each{ |lib| require lib }
db = KirbyBase.new:)local, nil, nil, './', '.tbl', './', true) #
requests that table indexes be created NOT when table is r
ead in but when it is first referenced

# create tables
newsitems = db.create_table( :datestr, {:DataType=>:String,
:Required=>true, :Index=>1})

# insert some data <= *interpreter never got to this*
newsitems.insert( '2008.03.25a', 'First Title', 'First URL', false,
'This is an extended summary of the news item.' )
newsitems.insert( '2008.03.25b', 'Second Title', 'Second URL',
false, 'This is another extended summary of the
news item.' )

end

This produced:

$ ruby kirbyaml.rb
/var/lib/gems/1.8/gems/KirbyBase-2.6/lib/kirbybase.rb:566:in
`create_table': Must have a field type for each field name (RuntimeError)
from kirbyaml.rb:31:in `main'
from kirbyaml.rb:42

Originally, I had several variables in the table, but reduced this to
one to try to find the error, and failed. I simply don't see it.

Reduced further, to this -

newsitems = db.create_table( :datestr, :String )

the same error is produced.

Can anyone give me a clue as to the problem?

Thanks,

Tom

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd
Bellingham, Washington, U.S.A: (360) 920-1226
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
T

Tom Cloyd

Tom said:
Jamey,

After a very long wait, I'm finally diving into the Kirbybase gem.

My problem is that I'm trying to create a table, following very
carefully the example given in the quite nice documentation (!), and
it's not working for me, and I cannot see the problem. The code
(stripped to essentials):

def main

%w(rubygems logger kirbybase yaml).each{ |lib| require lib }
db = KirbyBase.new:)local, nil, nil, './', '.tbl', './', true) #
requests that table indexes be created NOT when table is r
ead in but when it is first referenced

# create tables
newsitems = db.create_table( :datestr, {:DataType=>:String,
:Required=>true, :Index=>1})

# insert some data <= *interpreter never got to this*
newsitems.insert( '2008.03.25a', 'First Title', 'First URL', false,
'This is an extended summary of the news item.' )
newsitems.insert( '2008.03.25b', 'Second Title', 'Second URL',
false, 'This is another extended summary of the news item.' )

end
This produced:

$ ruby kirbyaml.rb
/var/lib/gems/1.8/gems/KirbyBase-2.6/lib/kirbybase.rb:566:in
`create_table': Must have a field type for each field name (RuntimeError)
from kirbyaml.rb:31:in `main'
from kirbyaml.rb:42

Originally, I had several variables in the table, but reduced this to
one to try to find the error, and failed. I simply don't see it.

Reduced further, to this -

newsitems = db.create_table( :datestr, :String )

the same error is produced.

Can anyone give me a clue as to the problem?

Thanks,

Tom
Sorry - didn't provide context -
Running KirbyBase 2.6 and Ruby 1.8.6 on Kubuntu Linux 7.10
t.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog)
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
J

Jamey Cribbs

Tom, you need to specify the table name when creating a table, i.e.:

newsitems = db.create_table:)news_items, :datestr, :String)


The symbol above, :news_items, will cause KB to create the table in a
physical file called news_items.tbl.


HTH,

Jamey
 
T

Tom Cloyd

Jamey,
Thanks so much for your prompt and helpful reply. I KNEW it has to be
something very basic which I didn't understand. I appear to have misread
the documentation. To wit:

plane_tbl = db.create_table:)plane, :name, :String, :country, :String,
:role, :String, :speed, :Integer, :range, :Integer, :began_service, :Date,
:still_flying, :Boolean)

In this code, I saw 'plane_tbl' as the probable table name (although I
realize that most immediately it is something else) - assuming that this
would be used by KirbyBase to open a file of that name. A complete misread.

:plane, :name, :String,

This appeared to be a listing of two variable names (table columns),
followed by their type. Wrong!

OK, so now I'm headed the right direction.

I've been wanting for quite some time to work with KirbyBase, and I
think I finally have a real need for it. Looking through the very nice
documentation you have prepared, I feel real admiration for the work you
have done. This all looks awfully well thought out and executed. And I'm
going to study the code to further my learning in Ruby. Thanks for all
your work.

I will (probably) be using this to manage a database of news item
summaries for stories with mental health topics, which database will be
used to generate html pages for my professional website. I wanted to be
able to edit directly in the db, if possible, and KB allows me to do
this. Terrific.

Thanks again for your speedy help. Much appreciated. I'm very eager to
dive into KirbyBase.

Tom

Jamey said:
Tom, you need to specify the table name when creating a table, i.e.:

newsitems = db.create_table:)news_items, :datestr, :String)


The symbol above, :news_items, will cause KB to create the table in a
physical file called news_items.tbl.


HTH,

Jamey
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog)
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
J

Jamey Cribbs

Glad I could help!

Jamey


Jamey,
Thanks so much for your prompt and helpful reply. I KNEW it has to be
something very basic which I didn't understand. I appear to have misread
the documentation. To wit:

plane_tbl = db.create_table:)plane, :name, :String, :country, :String,
:role, :String, :speed, :Integer, :range, :Integer, :began_service, :Date,
:still_flying, :Boolean)

In this code, I saw 'plane_tbl' as the probable table name (although I
realize that most immediately it is something else) - assuming that this
would be used by KirbyBase to open a file of that name. A complete misread.

:plane, :name, :String,

This appeared to be a listing of two variable names (table columns),
followed by their type. Wrong!

OK, so now I'm headed the right direction.

I've been wanting for quite some time to work with KirbyBase, and I
think I finally have a real need for it. Looking through the very nice
documentation you have prepared, I feel real admiration for the work you
have done. This all looks awfully well thought out and executed. And I'm
going to study the code to further my learning in Ruby. Thanks for all
your work.

I will (probably) be using this to manage a database of news item
summaries for stories with mental health topics, which database will be
used to generate html pages for my professional website. I wanted to be
able to edit directly in the db, if possible, and KB allows me to do
this. Terrific.

Thanks again for your speedy help. Much appreciated. I'm very eager to
dive into KirbyBase.

Tom





--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist

Bellingham, Washington, U.S.A: (360) 920-1226


<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog)
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
P

Peña, Botp

From: Tom Cloyd [mailto:[email protected]]=20
# I wanted to be able to edit directly in the db, if possible,=20
# and KB allows me to do this. Terrific.

that's the beauty there (as exemplified by kirbybase), all you need is =
ruby and you're good to go.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top