Skip to content

Support utf-8 files oracle_sql module #6

@kalemontes

Description

@kalemontes

Hello,
First things first, thanks for this collection, it's helping me a lots :)

I bumped into an encoding issue when using the oracle_sql module.

[UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128)](https://stackoverflow.com/questions/24475393/unicodedecodeerror-ascii-codec-cant-decode-byte-0xc3-in-position-23-ordinal)

First i though it was the file am using to insert data, but it is well encode (UTF-8) as i have non ansi on people's names. So i dug a bit and was able to patch this issue by adding the encoding open().

else:  # SQL file
        try:
            file_name = script.lstrip('@')
            with open(file_name, 'r', encoding="utf-8") as f:
                execute_statements(f.read())
            module.exit_json(msg='DML or DDL statements executed.', changed=True, statements=ora_db.ddls,
                             output_lines=output_lines)
        except IOError as e:
            module.fail_json(msg=str(e), changed=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions