views:

75

answers:

2

What would be equivalent of this in postgresql

run('echo "CREATE DATABASE %s;"|mysql --batch --user=%s --password=%s --host=%s' % (dataname, env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True)

The above works fine for creating mysql database, but how would you create one in postgresql without getting stuck at password prompt.

A: 

psql reads ~/.pgpass

You can also use non-password-based authentication methods. Consult PostgreSQL's documentation for more.

Alex Brasetvik
+1  A: 

You can:

Choose whatever suits you best. I would probably go with .pgpass.

depesz