pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jon Horsman <horshaq@gmail.com>
To: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to query information schema from shell script
Date: Sat, 28 Oct 2006 11:18:52 -0400
Message-ID: <4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com> (raw)
In-Reply-To: <1161976466.1655.1744.camel@state.g2switchworks.com>
References: <4f4c2a010610270631q73de201tb98446f64b942a0e@mail.gmail.com>
	<bc63ad820610270655h5bbc4fd4n797a7ea3d7e3bcdd@mail.gmail.com>
	<4f4c2a010610270657we83aa70o471678507d59c6a0@mail.gmail.com>
	<4f4c2a010610270812r65d321cejf00cb374596f2a5f@mail.gmail.com>
	<1161976466.1655.1744.camel@state.g2switchworks.com>

I ended up going the pg_catalog route, something like (off the top of
my head without a linux machine by to test it)

output=$(psql -d template1 -t -c "select * from pg_database where
datname='testdb'")
if [ -z "$output" ]; then
psql createdb testdb
else
echo 'the db already exists'
fi

I did the exact same thing for the user using pg_user and usename

Jon



view thread (11+ messages)

Message-ID: <4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com>
Permalink:  ../4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com/
Also on:    postgresql.org/message-id/4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: horshaq@gmail.com, smarlowe@g2switchworks.com
  Subject: Re: How to query information schema from shell script
  In-Reply-To: <4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox