PowerShell连接到Postgres DB [英] PowerShell connect to Postgres DB

查看:1047
本文介绍了PowerShell连接到Postgres DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以告诉你是否有一种方法如何从PowerShell连接到Postgres SQL DB,而不安装任何数据库驱动程序?我在寻找能够使用.NET数据库功能连接的解决方案。感谢。

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.

马修

推荐答案

您可以简单地执行 psql 命令行,然后读取并处理其输出。这在调用 psql -qAt 和/或使用 \copy 时特别有用。

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.

否则您必须有某种客户端驱动程序。 Powershell没有针对PostgreSQL协议的内置支持代码,因此它无法与PostgreSQL进行通信,没有某种客户端驱动程序。 nPgSQL 将是最明显的选择,因为它在.NET中集成良好,仅由.NET程序集组成。你可能将nPgSQL捆绑为一个Powershell扩展...但是像往常一样,已经有人

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.

否则你可能想要安装psqlODBC,这是一个简单的 msiexec 然后可以使用通常的ODBC支持

Otherwise you probably want to install psqlODBC, which is a simple msiexec to install then usable using the usual ODBC support.

原因Powershell可以谈到MS SQL而不安装其他驱动程序是MS SQL的驱动程序内置)。

(The only reason Powershell can talk to MS SQL without installing additional drivers is that drivers for MS SQL are built in).

这篇关于PowerShell连接到Postgres DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆