0

I have a windows batch file (.bat) which executes some Oracle Queries.

I want to integrate this Batch Script in a QGIS Plugin.

How can I do this with Python?

The cx_Oracle Python extension module is not an option within my infrastructure here.

3
  • 1
    Here is an answer with an example that should do what you intend do. stackoverflow.com/questions/1818774/…
    – Matte
    Commented Jul 29, 2016 at 9:29
  • Your question is not too clear. What exactly is it that you want to achieve ? Python lets you execute any OS command, including shell scripts. Is it that you want to run a script that calls SQLPLUS to submit some SELECTS and you want read the results back ? You can just redirect the output of the script to a file, then read and parse it using Python. A pretty complex process when you could just run the queries directly from Python. Why is cx_oracle not possible ? Commented Jul 30, 2016 at 10:02
  • There are some restrictions from our IT department.
    – Stefan
    Commented Aug 3, 2016 at 7:44

1 Answer 1

0

I've found a way to call my Batch Script:

import os
os.system("C:\Windows\System32\cmd.exe /c z:\Scripts\myscript.bat")

Thank you Matte for the comment. The link puts me on the right path: "How to open a program with cmd.exe from Python" on stack overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.