SHARE
TWEET

Untitled

a guest Aug 25th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyodbc
  2. import configparser
  3. import sys
  4.  
  5. try:
  6.     config = configparser.ConfigParser()
  7.     config.read(sys.path[0] + '\configurationFile.ini')
  8.     default_settings = config['DEFAULT']
  9.  
  10.     server_name = default_settings['server_name']
  11.     database_name = default_settings['database_name']
  12.     user_id = default_settings['user_id']
  13.     database_password = default_settings['database_password']
  14.  
  15.     batch_id = input("Please enter batchid to be reset:")
  16.     sql_statement = "select RefId,JobId from [WMS_CHVDP].[dbo].[wms_JobsProcessTracker] where RefId='"+ batch_id +"'"
  17.  
  18. except Exception as e:
  19.     print(f'Error {e}')
  20.  
  21. try:
  22.     conn = pyodbc.connect('Driver={SQL Server};'
  23.                           'Server=' + server_name + ';'
  24.                           'Database=' + database_name + ';'
  25.                           'UID=' + user_id + ';'
  26.                           'PWD='+ database_password +';'
  27.                           "Trusted_Connection=No")
  28.  
  29.     cursor = conn.cursor()
  30.     cursor.execute(sql_statement)
  31.  
  32.     is_found = False
  33.  
  34.     for row in cursor:
  35.         print(row)
  36.         is_found = True
  37.         break
  38.  
  39.     if is_found:
  40.         #sql_pending_statement = "exec usp_crossRefCaller_pending @batchId=" + batch_id + ""
  41.         sql_exec_pending_statement = "exec [dbo].[usp_crossRefCaller_pending] ?"
  42.         values = (batch_id)
  43.         cursor.execute(sql_exec_pending_statement,batch_id)
  44.         print(f"Successfully put to pending batchid {batch_id}, please check!")
  45.     else:
  46.         print(f"Batch id {batch_id} is not found!")
  47.  
  48. except Exception as e:
  49.     print(f'Error: {e}')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top