Re: Creating DB programmatically?

Поиск
Список
Период
Сортировка
От Frank Bax
Тема Re: Creating DB programmatically?
Дата
Msg-id 4E1C339A.50401@sympatico.ca
обсуждение исходный текст
Ответ на Re: Creating DB programmatically?  (Roy's Email <rmw256@hotmail.com>)
Ответы Re: Creating DB programmatically?  (Pushpendra Singh Thakur <thakur@corexprts.com>)
Список pgsql-novice
On 07/12/11 03:31, Roy's Email wrote:
> Now I am particularly confused.  How do I issue "CREATE DATABASE ..."
> from my program? I thought that I needed a connection (PGconn) before I
> could execute a command and I don't believe I have a valid connection if
> my attempt to connect to a (non-existent) DB fails. [Does it change
> anything that I'm writing in C++ and using the 'libpq' interface?]



Let's assume for the moment; that you know how to connect to an existing
database and execute an SQL command like "SELECT ....".

Simply modify your code:
* change your connect command so it connects to "template1"
* change your "SELECT ..." statement to "CREATE DATABASE ..."
* close the connection and make a connection to database just created.



В списке pgsql-novice по дате отправления:

Предыдущее
От: Francisco Leovey
Дата:
Сообщение: Re: Creating DB programmatically?
Следующее
От: Pushpendra Singh Thakur
Дата:
Сообщение: Re: Creating DB programmatically?