如何使用 PowerShell 或 VBScript 将数据插入 Postgres 表?
我需要定期查询少数服务器上的事件日志并将特定事件插入 Postgres 表中。
我无法弄清楚如何使用 PowerShell 和/或 VBScript 通过 ODBC 将数据插入表中。 一般来说,我对 VBScript 和 PowerShell 相当熟悉,并且我可以编写一个有效的 SQL UPDATE 语句,我只是试图将两者结合在一起,这是我以前从未做过的。
我安装了 Postgres ODBC 驱动程序,配置了一个测试正常的数据源。
到目前为止,谷歌还没有帮助我,有人可以提供一些指导吗?
I need to periodically query the event logs on a handful of servers and insert specific events into a Postgres table.
I am having trouble figuring out how I can insert data into a table via ODBC using PowerShell and/or VBScript. I'm reasonably familiar with both VBScript and PowerShell generally, and I can craft a SQL UPDATE statement that works, I'm just trying to tie the two together, which I've never done before.
I have the Postgres ODBC driver installed, I've configured a data source which tests OK.
Google isn't helping me thus far, can someone provide some pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢您的回复。
我使用了更多的谷歌搜索,最终摸索了足够多的 ADO.NET 来让它工作,尽管它可能不一定是“正确的”。
Thanks for the response.
I used more Googling and eventually grokked enough ADO.NET to get it working, although it may not necessarily be "correct".
您的哪一部分遇到了问题? 你已经走了多远? 您有打开的连接吗? 你知道连接字符串的语法吗?
准备连接:
插入:
为了完整性,查询:
如果您需要 powershell,请尝试 这篇文章。
如果您需要知道连接字符串,请尝试 connectionstrings.com。
What part are you having trouble with? How far have you got? Do you have a connection open? Do you know the syntax of the connection string?
Prepare a connection:
insert:
for completeness, query:
If you want powershell, try this post.
If you need to know the connection string, try connectionstrings.com.