-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathStart-Pgsql.ps1
More file actions
29 lines (23 loc) · 950 Bytes
/
Start-Pgsql.ps1
File metadata and controls
29 lines (23 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Start-Pgsql {
param ()
# https://www.nuget.org/packages/Npgsql/4.0.16 lib/netstandard2.0/Npgsql.dll
$npgsqldll = Join-Path $PSScriptRoot 'Npgsql.dll'
Add-Type -Path $npgsqldll
$container = Start-Container -Image sqldatabase/postgres:18.0 -ContainerPort 5432
$builder = New-Object -TypeName Npgsql.NpgsqlConnectionStringBuilder
$builder['Database'] = 'sqldatabasetest'
$builder['Username'] = 'adminuser'
$builder['Password'] = 'qwerty'
$builder['Timeout'] = 5
$builder.Host = 'localhost'
$builder.Port = $container.port.ToString()
$connectionString = $builder.ToString()
$builder.Host = $container.ip.ToString()
$builder.Port = 5432
$remoteConnectionString = $builder.ToString()
return @{
containerId = $container.containerId
connectionString = $connectionString
remoteConnectionString = $remoteConnectionString
}
}