mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-18 16:31:26 -07:00
mysql_query: fix failing when single-row query contains commas
This commit is contained in:
parent
0dfd63a4cb
commit
a86282cd5e
3 changed files with 20 additions and 3 deletions
|
@ -20,8 +20,7 @@ options:
|
|||
query:
|
||||
description:
|
||||
- SQL query to run. Multiple queries can be passed using YAML list syntax.
|
||||
type: list
|
||||
elements: str
|
||||
type: raw
|
||||
required: yes
|
||||
positional_args:
|
||||
description:
|
||||
|
@ -123,7 +122,7 @@ DDL_QUERY_KEYWORDS = ('CREATE', 'DROP', 'ALTER', 'RENAME', 'TRUNCATE')
|
|||
def main():
|
||||
argument_spec = mysql_common_argument_spec()
|
||||
argument_spec.update(
|
||||
query=dict(type='list', elements='str', required=True),
|
||||
query=dict(type='raw', required=True),
|
||||
login_db=dict(type='str'),
|
||||
positional_args=dict(type='list'),
|
||||
named_args=dict(type='dict'),
|
||||
|
@ -183,6 +182,9 @@ def main():
|
|||
query_result = []
|
||||
executed_queries = []
|
||||
rowcount = []
|
||||
if isinstance(query, str):
|
||||
query = [query]
|
||||
|
||||
for q in query:
|
||||
try:
|
||||
cursor.execute(q, arguments)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue