| From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Creating DB programmatically? |
| Date: | 2011-07-12 08:19:49 |
| Message-ID: | ivh02f$fot$1@dough.gmane.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Wood | 2011-07-12 08:53:18 | Re: Creating DB programmatically? |
| Previous Message | Roy's Email | 2011-07-12 07:31:40 | Re: Creating DB programmatically? |