Re: [SQL] How to query information schema from shell script

2006-10-28 Thread Jon Horsman
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

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Richard Broersma Jr
> In my original email i forgot to mentioned i need to know if the > database exists or not from the shell script. If it doesn't exist i > would then create it. Currently i was just creating the db everytime > our db script is run (since it doesn't hurt the db) but this generates > the 'db alread

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Scott Marlowe
On Fri, 2006-10-27 at 10:12, Jon Horsman wrote: > In my original email i forgot to mentioned i need to know if the > database exists or not from the shell script. If it doesn't exist i > would then create it. Currently i was just creating the db everytime > our db script is run (since it doesn't

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread George Pavlov
simplest might be psql -l. > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jon Horsman > Sent: Friday, October 27, 2006 8:13 AM > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] How to query information schema from shell

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
For more information, i know how this is done using the pg_catalog but have yet to find out how its done with the information schema. select * from pg_catalog.pg_database where datname='test' will work for me but i can't find a solution with the IS. I'd prefer to use the IS if its as easily don

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
In my original email i forgot to mentioned i need to know if the database exists or not from the shell script. If it doesn't exist i would then create it. Currently i was just creating the db everytime our db script is run (since it doesn't hurt the db) but this generates the 'db already exists'

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
Thanks for the suggestions guys, i'll give this a try. Jon ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread William Leite Araújo
You can use "-c" option of psql client. Ex.: psql -p 5000 -d database -c "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"    2006/10/27, Jon Horsman <[EMAIL PROTECTED]>: Hey,I'm trying to figure out how i can query the postgres informationschema from a bourne shell

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread A. Kretschmer
am Fri, dem 27.10.2006, um 9:31:03 -0400 mailte Jon Horsman folgendes: > Hey, > > I'm trying to figure out how i can query the postgres information > schema from a bourne shell script on linux. I need to know if a > user/table exists. Does someone mind giving me a quick example of how You can

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread George Pavlov
> I'm trying to figure out how i can query the postgres information > schema from a bourne shell script on linux. I need to know if a > user/table exists. Does someone mind giving me a quick example of how > this works, is this possible? % for tn in `psql -Umnp -dmnp_gp -hstgdb0 -tA -c"select ta

[SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
Hey, I'm trying to figure out how i can query the postgres information schema from a bourne shell script on linux. I need to know if a user/table exists. Does someone mind giving me a quick example of how this works, is this possible? Thanks, Jon. ---(end of broadcast