Roy's Email, 12.07.2011 01:40:
> I would like to create my DB programmatically. I.e. If the DB does
> not already exist, I would like to be able to create (and populate)
> it from within my application. Is there some way to do this?
> Everything I see seems to require connecting to an existing DB before
> you can do anything.
>
Connect to one of the template databases (template0, template1) from within your program (those databases are always
there).
Then you have a valid connection through which you can execute the CREATE DATABASE statement.
You can also run a "SELECT datname FROM pg_database" using that connection to test if your database is already there.
Thomas