Initial Problem...

S

Safran von Twesla

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:in `do'
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
 

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

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top