# Ruby-MySql error

**URL:** <https://www.ruby-forum.com/t/ruby-mysql-error/108910>\
**Category:** Ruby\
**Created:** [July 9, 2007, 11:37am UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910 "2007-07-09T11:37:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 9, 2007, 11:37am UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/1 "2007-07-09T11:37:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 9, 2007, 3:00pm UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/2 "2007-07-09T15:00:50Z")

</div>

swanand deodhar wrote:

> 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](http://MySQL.com), etc)

2. Please post the entire exception trace.

- 
* * *

  - Travis D Warlick, Jr
  - Lead Developer
  - Operis Systems, LLC

* * *

---

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 10, 2007, 2:23am UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/3 "2007-07-10T02:23:13Z")

</div>

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/](http://www.tmtm.org/en/ruby/mysql/)

aRi  
-------------------------------------------|  
Nietzsche is my copilot

---

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 10, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/4 "2007-07-10T14:10:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 10, 2007, 2:18pm UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/5 "2007-07-10T14:18:27Z")

</div>

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 B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![swanand\_deodhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@swanand\_deodhar](https://www.ruby-forum.com/u/swanand_deodhar)\
**Post date:** [July 10, 2007, 7:18am UTC](https://www.ruby-forum.com/t/ruby-mysql-error/108910/6 "2007-07-10T07:18:35Z")

</div>

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
```
