To connect to the database I use this example. But I can't find lessons on how to create a database.
For example:
- connect to server
- create new database
- do something
- drop database
- close connection
Can anybody show me how to do it?
Thanks!
To connect to the database I use this example. But I can't find lessons on how to create a database.
For example:
Can anybody show me how to do it?
Thanks!
On
I believe you can create databases by issuing standard SQL commands just as you can create tables in a database, as long as you are using a user (e.g. admin or similarly entitled user) that has permissions to create new databases.
So, all you need is to connect to the DB with the right user and then issue SQL commands with db.SQLExecute, such as "create database newDBname".
Follow the manual on how to create a database cluster:
http://www.postgresql.org/docs/9.1/interactive/creating-cluster.html
The database and users are created only once and you can use the client applications for that. Or are you trying to do it automatically as part of a software install package? After that you connect to it as many times as needed.