rdb2pg - insert an rdb table into a PostgreSQL database
rdb2pg [param=value ...]
rdb2pg uses an IRAF-compatible parameter interface. A template parameter file is in /proj/axaf/simul/lib/uparm/rdb2pg.par.
stdin, it reads from the UNIX standard input stream.
PGHOST environmental variable.
field and def.
defs=runid=int4,name=text
copy|insertcopy method is much faster, but is more finicky, and may
lead to the Broken Pipe message discussed below. The
insert method is much slower.
flag=value
syntax.
rdb2pg will enter the data from an RDB database into a PostgreSQL database table, optionally creating the database and the table if they do not exist. It automatically determines the PostgreSQL data type from the column definition in the RDB file, but may be overriden via a series of definition files or directly via one of its parameters.
The target database and table are specified by the db and table
parameters. If they do not exist, and the createdb parameter is
set, they will be created. Table field definitions are determined
in the following order:
float8, everything else is made text.
defs_files parameter
are parsed, in order. The files must be valid RDB files,
with two columns, field and def.
defs parameter is consulted, effectively
overriding everthing else.
If the table exists, its fields and their types are compared against those determined for the RDB table. If intersection is `no', discrepancies are treated as errors, are reported, and rdb2pg terminates. If intersection is `yes', only in the intersection of the RDB and PostgreSQL tables are considered.
Numeric fields are checked for correctness (otherwise PostgreSQL
burps), and those which are the strings N/A or NA
(lower case as well) are passed as null entries to PostgreSQL.
Empty fields are passed to PostgreSQL as null fields.
No other input checking is performed. If there are input problems,
and the copy method is being used,
the connection to PostgreSQL will (unfortunately) die ungracefully
with a Broken Pipe message, and will cause rdb2pg to
terminate unconditionally, without any cleanup (i.e., aborting
the current transaction). Other times, it may print out
a resetting connection message. If you can't narrow down
the problem, try using the insert method, which while slower,
should give you more useful error messages.
If verbose is true, a continuously updated report of rdb2pg's activity is printed,
If you get the message
Broken Pipe
or
resetting connection
one of the data values is incompatible with the type that you specified.
Diab Jerius ( djerius@cfa.harvard.edu )