Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capturing error from sql
#1
Hi - very new to python. I have a function that connects to teradata using jdwh. The function works well but the function returns nothing when there is an sql error. Function is as shown below - I’m advised that jdwh will return “exit code 1” if there was an error:

def db_execute(sql,ret='stdout'):

ret_type = {'stdout': 0 , 'out': 0, 'err':1, 'error':1, 'stderror':1}

args = ['jdwh']

db_cmd = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)

out = db_cmd.communicate(input = sql)

if ret_type[ret] not in list(ret_type.values()):
return None
return out[ret_type[ret]]

Any help appreciated.
Reply
#2
Please use Python tags to retain the indentation of your code. See the BBCode link in my signature below for details.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Capturing inputs values from internal python script limors11 11 2,008 Jun-16-2019, 05:05 PM
Last Post: DeaD_EyE
  Capturing a snapshot from the video sreeramp96 1 1,082 May-24-2019, 07:02 AM
Last Post: heiner55
  HTTP response capturing issue miunika 1 881 Mar-16-2019, 01:46 PM
Last Post: Larz60+
  HTTP response capturing issue anna 2 1,141 Mar-15-2019, 03:08 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020