Hi!
I was doing some really really simple stuff with Ruby DBI...
new_conn = DBI.connect("DBI:Mysql:test:localhost", "root", "pwd")
new_conn.tables.each do |table|
new_conn.columns(table).each do |columninfo|
print columninfo['name']
end
end
and strangely enough i am encountering this error:
Mysql.rb:662
`column_info': undefined method `is_not_null?' for #<Mysql::Field:Table>
Any ideas or has anyone encountered this kind of an error before?
Thanks and regards,
Swanand
···
---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
swanand deodhar wrote:
Hi!
I was doing some really really simple stuff with Ruby DBI...
new_conn = DBI.connect("DBI:Mysql:test:localhost", "root", "pwd")
new_conn.tables.each do |table|
new_conn.columns(table).each do |columninfo|
print columninfo['name']
end
end
and strangely enough i am encountering this error:
Mysql.rb:662
`column_info': undefined method `is_not_null?' for #<Mysql::Field:Table>
Any ideas or has anyone encountered this kind of an error before?
2 Things:
1) Where did you get your Mysql driver? (eg. ActiveRecord gem, from
MySQL.com, etc)
2) Please post the entire exception trace.
···
-
*************************************
* Travis D Warlick, Jr
* Lead Developer
* Operis Systems, LLC
*************************************
Ok, I honestly just worked with this.
DBI is pretty low level, and I had some problems with it.
You're encountering an error with the library itself, so you might want to either email the writer, or use something a little higher level.
I recommend Ruby/Mysql. Pure Ruby
http://www.tmtm.org/en/ruby/mysql/
aRi
-------------------------------------------|
Nietzsche is my copilot
Hi!
I downloaded the tarball from
http://www.tmtm.org/en/ruby/mysql/
The issue was resolved when i commented following code
retval << {
# Standard Ruby DBI column attributes
'name' => col.name,
'sql_type' => sql_type,
'type_name' => type_name,
'precision' => col.length,
'scale' => col.decimals,
#'nullable' => !col.is_not_null?, (commented by me)
'indexed' => ((col.flags & indexed) != 0),
#||col.is_pri_key?, (commented by me)
#'primary' => col.is_pri_key?, (commented by me)
'unique' => ((col.flags & unique_key_flag) != 0),
#||col.is_pri_key?, (commented by me)
# MySQL-specific attributes (signified by leading "mysql_")
'mysql_type' => col.type,
'mysql_type_name' => mysql_type_name,
'mysql_length' => col.length,
'mysql_max_length' => col.max_length,
'mysql_flags' => col.flags
}
}
Here is the entire stack trace:
c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:662:in `column_info':
undefined method `is_not_null?' for #<Mysql::Field:Field> (NoMethodError)
from c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:648:in `each'
from c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:648:in `column_info'
from c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:573:in `execute'
from c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:570:in `synchronize'
from c:/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:570:in `execute'
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:888:in `execute'
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:480:in `execute'
from dbi-demo.rb:4
from dbi-demo.rb:3:in `each'
from dbi-demo.rb:3
The code by me (This is running perfect when i comment code
as mentioned above)
require "dbi"
new_conn = DBI.connect("DBI:Mysql:summer_development:localhost",
"root", "")
new_conn.tables.each do |table|
all_columns = new_conn.execute("desc #{table}")
for column in all_columns
puts column
end
end
···
---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
Wait, so you commented the code and it ran perfectly? THat was it?
Weird. Probably just a quirk of technology.
My friend has a microwave you can only open by hitting it on the head.
Sorry I couldn't help you sooner
aRi
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.
Hi!
lol!!!!! guess metaphor fits in perfectly...and yes, when i commented the code, it ran perfectly...anyways, thank you and to all for helping.
Thanks and regards,
Swanand
Ari Brown <ari@aribrown.com> wrote: Wait, so you commented the code and it ran perfectly? THat was it?
Weird. Probably just a quirk of technology.
My friend has a microwave you can only open by hitting it on the head.
Sorry I couldn't help you sooner
aRi
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.
···
---------------------------------
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.