Automating databse creation - Mailing list pgsql-general

From Ashish Karalkar
Subject Automating databse creation
Date
Msg-id 003a01c74c1f$6d966b20$170211ac@LIONKING.COM
Whole thread Raw
Responses Re: Automating databse creation  (Thomas Pundt <mlists@rp-online.de>)
Re: Automating databse creation  ("Bruce McAlister" <bruce.mcalister@blueface.ie>)
List pgsql-general
Hello list,
I want to automate database creation, user creation,table creation via script. this script will be run by an external programme to postgresql server.
is there any way?
 
what i want to do is as follows:
 
 

#!/bin/sh

su - postgres

TIMEDUMP=`date +%Y%m%d"_"%H%M`

PG_PATH=/usr/local/pgsql/bin

${PG_PATH}/pg_dump -d qsweb -U postgres -p 5432 -Ft -f /usr/local/pgsql/data/backup/BACKUP_QSWEB_${TIMEDUMP}.tar

echo ' Backup of Database for Quick School kept at path /usr/local/pgsql/data/backup/BACKUP_QSWEB_${TIMEDUMP}.tar'

${PG_PATH}/dropdb  -U qsweb qsweb

echo ' Old Database for Quick School Dropped'

${PG_PATH}/dropuser qsweb

echo ' Old user qsweb for Quick School Dropped'

${PG_PATH}/createuser -s qsweb

echo ' New user qsweb for Quick School created'

${PG_PATH}/createdb -O qsweb qsweb

echo ' New Database qsweb for Quick School created'

${PG_PATH}/createlang -U qsweb -d qsweb plpgsql

echo ' Database language plpgqslfor Quick School created'

echo ' Database for Quick School created. Please run the Create_Tables.sql script'

${PG_PATH}/psql -U qsweb qsweb

and then Run  Create_Tables.sql

_EOF_

 

 

is there any way??

right now the scripts stop after switching over to postgres user.

 

With regards

Ashish...

 

pgsql-general by date:

Previous
From: johnf
Date:
Subject: does anyone have a tool to convert SP'sT-SQL to Postgres
Next
From: "A. Kretschmer"
Date:
Subject: Re: does anyone have a tool to convert SP'sT-SQL to Postgres