• <i id='vyQg5'><tr id='vyQg5'><dt id='vyQg5'><q id='vyQg5'><span id='vyQg5'><b id='vyQg5'><form id='vyQg5'><ins id='vyQg5'></ins><ul id='vyQg5'></ul><sub id='vyQg5'></sub></form><legend id='vyQg5'></legend><bdo id='vyQg5'><pre id='vyQg5'><center id='vyQg5'></center></pre></bdo></b><th id='vyQg5'></th></span></q></dt></tr></i><div id='vyQg5'><tfoot id='vyQg5'></tfoot><dl id='vyQg5'><fieldset id='vyQg5'></fieldset></dl></div>

    <small id='vyQg5'></small><noframes id='vyQg5'>

    1. <tfoot id='vyQg5'></tfoot>

        • <bdo id='vyQg5'></bdo><ul id='vyQg5'></ul>

        <legend id='vyQg5'><style id='vyQg5'><dir id='vyQg5'><q id='vyQg5'></q></dir></style></legend>

        Ansible 中的 SQL Server 数据库查询

        时间:2023-06-06
        • <tfoot id='pUKjR'></tfoot>

            1. <small id='pUKjR'></small><noframes id='pUKjR'>

            2. <legend id='pUKjR'><style id='pUKjR'><dir id='pUKjR'><q id='pUKjR'></q></dir></style></legend>
                <bdo id='pUKjR'></bdo><ul id='pUKjR'></ul>

                    <tbody id='pUKjR'></tbody>

                  <i id='pUKjR'><tr id='pUKjR'><dt id='pUKjR'><q id='pUKjR'><span id='pUKjR'><b id='pUKjR'><form id='pUKjR'><ins id='pUKjR'></ins><ul id='pUKjR'></ul><sub id='pUKjR'></sub></form><legend id='pUKjR'></legend><bdo id='pUKjR'><pre id='pUKjR'><center id='pUKjR'></center></pre></bdo></b><th id='pUKjR'></th></span></q></dt></tr></i><div id='pUKjR'><tfoot id='pUKjR'></tfoot><dl id='pUKjR'><fieldset id='pUKjR'></fieldset></dl></div>
                  本文介绍了Ansible 中的 SQL Server 数据库查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想知道社区中是否有人使用 Ansible 操作过 Microsoft SQL Server 数据库?

                  I would like to find out if anyone in the community has used Ansible to manipulate a Microsoft SQL Server database?

                  我们想向我们用 Ansible 编写的环境配置脚本添加一个任务,该脚本将 INSERT 行插入到 SQL Server 表中.这些行将具有在我们的变量文件中指定的参数.

                  We want to add a task to our environment configuration scripts written in Ansible that will INSERT rows into a SQL Server table. The rows will have parameters that are specified in our variables files.

                  我一直无法找到实现此目的的特定 Ansible 模块,所以想听听是否有人在其他方面取得了成功?

                  I have been unable to locate a specific Ansible module for achieving this so would like to hear if anyone has has success in some other way?

                  推荐答案

                  为了完整起见,这里是 Ansible to SELECT & 中使用的解决方案的语法.插入 Microsoft SQL Server:

                  For completeness here is the syntax of the solution used in Ansible to SELECT & INSERT for Microsoft SQL Server:

                  插入

                  - name: 'insert row to SQL server DB'
                    win_shell: "invoke-sqlcmd -username \"{{db_user}}\" -password \"{{db_pass}}\" -Query \"INSERT INTO Addresses (DoorNum,Street,Town,PostCode) VALUES ({{ item.doornum }},'{{ item.street }}','{{ item.town }}''{{ item.postcode }}')\""
                  

                  选择

                  - name: 'select from SQL server DB'
                    win_shell: "invoke-sqlcmd -username \"{{db_user}}\" -password \"{{db_pass}}\" -Query \"SELECT ID FROM Addresses WHERE PostCode = '{{ item.postcode }}'\" | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors | ConvertTo-Json"
                    register: response
                  
                  - set_fact:
                      ids: "{{ response.stdout|from_json}}"
                  
                  - debug:
                      var: ids
                  

                  这篇关于Ansible 中的 SQL Server 数据库查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在ansible中为不同的主机使用另一个任务中的 下一篇:无法更改 root 帐户 ansible 的密码

                  相关文章

                  最新文章

                  <legend id='rju6h'><style id='rju6h'><dir id='rju6h'><q id='rju6h'></q></dir></style></legend>

                    1. <i id='rju6h'><tr id='rju6h'><dt id='rju6h'><q id='rju6h'><span id='rju6h'><b id='rju6h'><form id='rju6h'><ins id='rju6h'></ins><ul id='rju6h'></ul><sub id='rju6h'></sub></form><legend id='rju6h'></legend><bdo id='rju6h'><pre id='rju6h'><center id='rju6h'></center></pre></bdo></b><th id='rju6h'></th></span></q></dt></tr></i><div id='rju6h'><tfoot id='rju6h'></tfoot><dl id='rju6h'><fieldset id='rju6h'></fieldset></dl></div>

                    2. <small id='rju6h'></small><noframes id='rju6h'>

                        <bdo id='rju6h'></bdo><ul id='rju6h'></ul>

                    3. <tfoot id='rju6h'></tfoot>