Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Best MySQL date/time data type when using Ruby?

Reply
Thread Tools

Best MySQL date/time data type when using Ruby?

 
 
John N Joyner
Guest
Posts: n/a
 
      07-11-2007
In the years when I used PHP to develop web apps, I found either a MySQL
TIMESTAMP or an integer of the same value was most convenient for
storing date/time information and then converting back and forth using
PHP functions.

Now that I'm using Ruby, I'm wondering whether the MySQL DATETIME type
might be a better match with the Ruby Date class and its methods, based
on looking at the Date class documentation. I'd be interested to know
whether Rubyists who use MySQL mostly use the DATETIME data type or the
TIMESTAMP data type? (I'm not using ROR, though I have nothing against
it.)

Any input much appreciated.
--
John N Joyner
Ruby, MySQL, Pair Networks

 
Reply With Quote
 
 
 
 
John Joyce
Guest
Posts: n/a
 
      07-11-2007

On Jul 10, 2007, at 8:36 PM, John N Joyner wrote:

> In the years when I used PHP to develop web apps, I found either a
> MySQL
> TIMESTAMP or an integer of the same value was most convenient for
> storing date/time information and then converting back and forth using
> PHP functions.
>
> Now that I'm using Ruby, I'm wondering whether the MySQL DATETIME type
> might be a better match with the Ruby Date class and its methods,
> based
> on looking at the Date class documentation. I'd be interested to know
> whether Rubyists who use MySQL mostly use the DATETIME data type or
> the
> TIMESTAMP data type? (I'm not using ROR, though I have nothing against
> it.)
>
> Any input much appreciated.
> --
> John N Joyner
> Ruby, MySQL, Pair Networks
>


You don't need to use Rails to use its database ORM component
ActiveRecord. ActiveRecord doesn't do the timestamp mysql type really
the way you would expect (AFAIK). It instead chooses to simple store
a datetime and let you manage that date data in Ruby code instead.

If you choose to use Ruby DBI gem, it is more what you might be used
to with PHP or Perl more direct SQL stuff.

Either approach works pretty well in Ruby, since the Ruby classes
Time and Date have a lot of nice functionality built in.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python and Connecting to MySQL remotely WITHOUT MySQL installedon local computer dave Python 4 11-18-2010 04:19 AM
Restricting a type by using an attribute on the element using the type? Arndt Jonasson XML 2 02-12-2007 10:09 AM
using mysql client to read a file to create a table in a database in a mysql server julian Ruby 8 04-06-2006 10:29 AM
Python MySQL API and date data type Yong Wang Python 1 08-27-2004 07:54 AM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. luna ASP .Net 1 02-13-2004 01:15 PM



Advertisments