kaa
kaa

Reputation: 1367

RealStudio and PostgreSQL

To connect to the database I use this example. But I can't find lessons on how to create a database.

For example:

  1. connect to server
  2. create new database
  3. do something
  4. drop database
  5. close connection

Can anybody show me how to do it?

Thanks!

Upvotes: 0

Views: 422

Answers (3)

Thomas Tempelmann
Thomas Tempelmann

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

BKeeney Software
BKeeney Software

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

Clodoaldo Neto
Clodoaldo Neto

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

Related Questions