Initial Problem

Hi group,

well, I’m trying to run an example rb-script, but I keep getting
errors…

The script:
@ http://ruby-dbi.sourceforge.net/

···

############################################
require ‘dbi’

connect to a datbase

here i have set an existing database name with a valid login/auth

dbh = DBI.connect(‘DBI:Mysql:test’, ‘testuser’, ‘testpwd’)

puts "inserting…"
1.upto(13) do |i|
sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)"
dbh.do(sql, “Song #{i}”, “#{i*10}”)
end

puts "selecting…"
sth=dbh.prepare(‘select * from simple01’)
sth.execute

while row=sth.fetch do
p row
end

puts "deleting…"
dbh.do(‘delete from simple01 where internal_id > 10’)

dbh.disconnect
############################################

First I get the “inserting” - String printed on screen and then
following:

/usr/local/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:265:in do': Duplicate entry '0' for key 1 (DBI::DatabaseError) from /usr/local/lib/ruby/site_ruby/1.8/dbi/dbi.rb:647:indo’
from ./test3.rb:11
from ./test3.rb:9:in `upto’
from ./test3.rb:9

On mysql, there is one dataset which has been written into the db.

I have a self-compiled ruby-1.8.1 and ruby-dbi and ruby-mysql
installed. All that on Linux Mdk 8.2.

Any help welcome

Thanx

SvT