PostgreSQL
This section describes how to start up an instance of a PostgreSQL Server database.

Creating a PostgreSQL Server instance.

Create a new instance of Bard.Db.PostgresDatabasepassing in the database name, username , password and port number.
1
var db = new PostgresDatabase(
2
databaseName: "PostgreSQL_latest",
3
postgresUser: "Db_user",
4
password: "Password1",
5
portNumber: "5432",
6
tagName: "latest");
Copied!
Port number, and tagName are optional. If they are not supplied then the default value is
latest & 5432

Starting up the Database

To start the database instance simply call either. The result is the IP address of the host machine in case this is needed in the connection string.
​
Sync
Async
1
var result = db.StartDatabase();
Copied!
1
var result = await db.StartDatabaseAsync();
Copied!
This may take a little time the first time as Docker needs to download the image in the background.

Stopping the Database

To stop the database simply call.
Sync
Async
1
db.StopDatabase();
Copied!
1
await db.StopDatabaseAsync();
Copied!
Last modified 1yr ago