PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Conecte-se ao banco de dados PostgreSql remoto usando o Powershell


Consulte:https://odbc.postgresql.org/
Download:https://www.postgresql.org/ftp/odbc/versions/msi/

Fontes de dados (ODBC) no Windows:Iniciar → Pesquisar → odbc → User DSN → Adicionar/Configurar



Exemplo :
$MyServer = "<ip>"
$MyPort  = "5432"
$MyDB = "<database>"
$MyUid = "<user>"
$MyPass = "<pass>"

$DBConnectionString = "Driver={PostgreSQL UNICODE(x64)};Server=$MyServer;Port=$MyPort;Database=$MyDB;Uid=$MyUid;Pwd=$MyPass;"
$DBConn = New-Object System.Data.Odbc.OdbcConnection;
$DBConn.ConnectionString = $DBConnectionString;
$DBConn.Open();
$DBCmd = $DBConn.CreateCommand();
$DBCmd.CommandText = "SELECT * FROM tb_module;";
$DBCmd.ExecuteReader();
$DBConn.Close();