Skip to content

Commit

Permalink
Merge pull request #69 from bartowl/fix_68
Browse files Browse the repository at this point in the history
fix for quoted sqldelim fixes #68
  • Loading branch information
Rendanic authored Sep 23, 2021
2 parents 84515db + bbab9ff commit 00a0491
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/oracle_sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ EXAMPLES = '''
script: /u01/scripts/create-tables-and-insert-default-values.sql
'''
import os
import re
from ansible.module_utils.basic import AnsibleModule

try:
Expand Down Expand Up @@ -228,8 +229,11 @@ def main():
else:
sqldelim = ';'

# fixed problems with quoted sqldelim using
# https://stackoverflow.com/questions/2785755/how-to-split-but-ignore-separators-in-quoted-strings-in-python
PATTERN = re.compile(r'''((?:[^''' + sqldelim + r'''"']|"[^"]*"|'[^']*')+)''')
sqlfile = sqlfile.strip(sqldelim)
sql = sqlfile.split(sqldelim)
sql = PATTERN.split(sqlfile)[1::2]

for q in sql:
execute_sql(module, cursor, conn, q)
Expand Down

0 comments on commit 00a0491

Please sign in to comment.