Hot answers tagged scripting
1
From the documentation:
createdb is a wrapper around the SQL command CREATE DATABASE.
There is no effective difference between creating databases via this
utility and via other methods for accessing the server.
This means that you can write a script which issues a command like
psql -f createdb.sql -v passwd=$passwd -v user=$user
Where ...
1
In order to connect to your PostgreSQL instance and run the createdb script, which is a client, you can use a password file. This file is generally located at ~/.pgpass and must contain theses information :
hostname:port:database:username:password
If you want to use a different path for your password file, you can set the PGPASSFILE environment variable.
...
Only top voted, non community-wiki answers of a minimum length are eligible
