Reputation: 1367
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!
Upvotes: 0
Views: 422
Reputation: 12095
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".
Upvotes: 0
Reputation: 1299
Since you are creating a new database and then dropping it, why not use the built-in SQLite database? You can do a completely in-memory database that will be lightning fast (unless you fill up available RAM).
Upvotes: 1
Reputation: 125414
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.
Upvotes: 1