On Aug 5, 2007, at 6:07 PM, Michael Glaesemann wrote:
>
> On Aug 5, 2007, at 16:31 , Perry Smith wrote:
>
>> I'm trying to help out the rails people. Currently they have
>> "rake" scripts which call pg_dump, dropdb, createdb, and psql. It
>> would be nicer if this could be done via a database connection.
>
> Why would this be nicer? What's the advantage? pg_dump in
> particular *is* a client application. It isn't called from within
> another connection. As loading a schema from a file via psql,
> that's also fairly common practice. Alternatives to createdb or
> dropdb are just as easily handled by passing a command to psql
> using its -c flag. Another point to consider is that using CREATE/
> DROP DATABASE instead of the createdb/dropdb client applications
> requires a database connection: if you don't have a database to
> connect to, you can't use them. Of course, you could initially
> connect to the postgres database (or template1 in older version),
> but that could require configuring parameters for another database
> in database.yml. What's the advantage?
Connecting to the postgres database is pretty trivial. If you want
to create foo_development, you use all config stanza for development
replace the database name with "postgres" (or "template1"). If you
want to dump foo_development, it better be there! :-)
I just submitted a patch to do create_database and drop_database to
the postgresql adapter. I wanted to complete the other two missing
pieces.
The rake code for postgesql in this area is uglier than the mysql
code. I mostly just wanted to clean it up. And, one problem I have
is, often, pg_dump is not in my path.
I find it odd that you are resistant to the idea. To me, the
advantages are clear if it can be done without a tremendous amount of
work. Why horse around with the environment variables to set such
things as password, call sh, just to call pg_dump.
Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )
Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems