melmorabity / ansible-mssql-query Goto Github PK
View Code? Open in Web Editor NEWAnsible module to run a SQL query on a Microsoft SQL Server database
License: GNU General Public License v3.0
Ansible module to run a SQL query on a Microsoft SQL Server database
License: GNU General Public License v3.0
Using below query fails.
- name: query
mssql_query:
login_user: sa
login_password: "{{ sql_admin_password }}"
login_host: localhost
db: msdb
#as_dict: true
query: >
SELECT bcks.database_name, bckS.backup_start_date, bckS.backup_finish_date, CAST(bcks.backup_size / 1073741824.0E AS DECIMAL(10, 2)) as [Backup Size(GB)],
is_compressed, is_encrypted, physical_device_name
FROM msdb.dbo.backupset bckS INNER JOIN msdb.dbo.backupmediaset bckMS
ON bckS.media_set_id = bckMS.media_set_id
INNER JOIN msdb.dbo.backupmediafamily bckMF
ON bckMS.media_set_id = bckMF.media_set_id
WHERE bckS.backup_finish_date > (SELECT CONVERT(varchar, getdate(), 23))
ORDER BY bckS.backup_start_date DESC
register: backupset
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Value of unknown type: <class 'decimal.Decimal'>, 730.48
fatal: [xx.xx.xx.xx]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 102, in <module>\n File \"<stdin>\", line 94, in _ansiballz_main\n File \"<stdin>\", line 40, in invoke_module\n File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/modules/mssql_query.py\", line 168, in <module>\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/modules/mssql_query.py\", line 164, in main\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 2072, in exit_json\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 2065, in _return_formatted\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 422, in remove_values\n File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 401, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'decimal.Decimal'>, 730.48\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Executing the query manually produces no error. Seems that the module does not support decimal datatypes in the output.
Hello there,
Can you kindly provide us with an example of how to execute a complex SQL Statement, or to compile a procedure or a function?
Is there any way we can execute a SQL file?
Kindly assist.
Thank you
Ameya Agashe
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.