Python code is working fine. I need to suppress this warning to the end user. Can anyone help me how to do that in python??? Can anyone help me to explain this error.
Error = [Microsoft][ODBC Driver 17 for SQL Server]Warning: BCP import with a format file will convert empty strings in delimited columns to NULL.
I tried this but it is not working.
import warnings
warnings.filterwarnings('ignore')
#This is a python code.
import pyodbc
import subprocess
Exception Handling
try:
# Trusted Connection to Named Instance
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=catalystmetals.database.windows.net;DATABASE=CatalystQuest;UID=Automation;PWD=abc')
cursor=connection.cursor()
sqlCommand1="""
Exec esusp_MRA_Report_SL4_HDR;;
"""
sqlCommand2="""
Exec esusp_MRA_Report_SL4;;
"""
# Call Stored Procedure
cursor.execute(sqlCommand1)
cursor.execute(sqlCommand2)
connection.commit()
# SELECT Query After Stored Procedure Call - Check table contents
subprocess.run("bcp MDR.MDReportHeader out C:\\ClientData\\Catalyst\\MRT\\SL4_HDR.txt -S catalystmetals.database.windows.net -d CatalystQuest -U Automation -Pabc -q -c -t \t")
subprocess.run("bcp MDR.MDReport out C:\\ClientData\\Catalyst\\MRT\\SL4_Data.txt -S catalystmetals.database.windows.net -d CatalystQuest -U Automation -Pabc -q -c -t \t")
subprocess.run("copy C:\\ClientData\\Catalyst\\MRT\\SL4_HDR.txt + C:\\ClientData\\Catalyst\\MRT\\SL4_Data.txt C:\\ClientData\\Catalyst\\MRT\\SL4.txt", shell=True)
subprocess.run("del C:\\ClientData\\Catalyst\\MRT\\SL4_HDR.txt", shell=True)
subprocess.run("del C:\\ClientData\\Catalyst\\MRT\\SL4_Data.txt", shell=True)
except pyodbc.Error as ex:
print("Exception: ",ex)
cursor.close()
connection.close()
print("Closing program...")
exit()
so does this resolve your issue, all we see if a wall of code
anyways take a look also at this discord channel for more python help
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.