Empty to NULL conversion - Ruby - Postgres ?

From: Venks <venkatesh(dot)mantha(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Empty to NULL conversion - Ruby - Postgres ?
Date: 2008-02-02 01:33:41
Message-ID: 96bd3d570802011733h4074f441l2ef02c8618f70fd2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I am trying to copy some data from MySQL to Postgres using Ruby. This
is NOT a MySQL to PostgreSQL conversion project. I need to read the
data from a MySQL database and load it into PostgreSQL database.

How do I handle "nil" in ruby and convert them into NULL so that I can
insert NULL into INT columns instead of empty values? In short I am
getting the following popular error:

invalid input syntax for integer: "" (PGError)

This is because when I read data from MySQL, all the NULL values are
converted into "nil" in Ruby and inserting them into Postgres is an
issue because "nil" is being transmitted as "" (empty) and not as SQL
NULL.

-Venks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2008-02-02 01:48:19 Re: Empty to NULL conversion - Ruby - Postgres ?
Previous Message Greg Smith 2008-02-02 01:20:37 Re: Good F/OSS license summary