Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyodbc
- import configparser
- import sys
- try:
- config = configparser.ConfigParser()
- config.read(sys.path[0] + '\configurationFile.ini')
- default_settings = config['DEFAULT']
- server_name = default_settings['server_name']
- database_name = default_settings['database_name']
- user_id = default_settings['user_id']
- database_password = default_settings['database_password']
- batch_id = input("Please enter batchid to be reset:")
- sql_statement = "select RefId,JobId from [WMS_CHVDP].[dbo].[wms_JobsProcessTracker] where RefId='"+ batch_id +"'"
- except Exception as e:
- print(f'Error {e}')
- try:
- conn = pyodbc.connect('Driver={SQL Server};'
- 'Server=' + server_name + ';'
- 'Database=' + database_name + ';'
- 'UID=' + user_id + ';'
- 'PWD='+ database_password +';'
- "Trusted_Connection=No")
- cursor = conn.cursor()
- cursor.execute(sql_statement)
- is_found = False
- for row in cursor:
- print(row)
- is_found = True
- break
- if is_found:
- #sql_pending_statement = "exec usp_crossRefCaller_pending @batchId=" + batch_id + ""
- sql_exec_pending_statement = "exec [dbo].[usp_crossRefCaller_pending] ?"
- values = (batch_id)
- cursor.execute(sql_exec_pending_statement,batch_id)
- print(f"Successfully put to pending batchid {batch_id}, please check!")
- else:
- print(f"Batch id {batch_id} is not found!")
- except Exception as e:
- print(f'Error: {e}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement