Can you please advise whether there's a way how to connect to Postgres SQL DB from PowerShell WITHOUT installing any DB driver? I'm looking for solution which would be able to connect using only .NET database capabilities. Thanks.
Matthew
Can you please advise whether there's a way how to connect to Postgres SQL DB from PowerShell WITHOUT installing any DB driver? I'm looking for solution which would be able to connect using only .NET database capabilities. Thanks.
Matthew
With no client driver at all, you can simply execute the psql
command-line then read and process its output. This is particularly useful when invoking it as psql -qAt
and/or using \copy
.
Otherwise you must have some kind of client driver. Powershell has no built-in support code for the PostgreSQL protocol, so it therefore cannot communicate with PostgreSQL without some kind of client driver. nPgSQL would be the most obvious choice since it integrates well in .NET and is composed only of .NET assemblies. You could probably bundle nPgSQL up as a Powershell extension... but as usual, someone already did that.
Otherwise you probably want to install psqlODBC, which is a simple msiexec
to install then usable using the usual ODBC support.
(The only reason Powershell can talk to MS SQL without installing additional drivers is that drivers for MS SQL are built in).