connection = pypyodbc.connect('Driver={SQL Server};'
'Server=FRCLG11BSMSQL1\BSMSQLSERVER;'
'Database=VWT_BSM_MGT;'
'uid=power;pwd=apm$vwt2017xx')
cursor = connection.cursor()
target = open("D:\\Users\\walid.laasmi\\Desktop\\db_output.csv", 'w')
SQLCommand = "SELECT HOST_NAME, HOST_KEY FROM VWT_BSM_MGT.dbo.EUMBPM_HOSTS order by HOST_NAME"
target.write("HOST_NAME,HOST_KEY")
target.write("\n")
rows=cursor.execute(SQLCommand)
for row in rows:
print(row)
stri=str(row)
strii=stri.replace("('","")
striii=strii.replace("', '",",")
target.write(striii.replace("')",""))
target.write("\n")
#p = subprocess.run(['D:\\Users\\walid.laasmi\\Desktop\\new.cmd'])
#p.communicate(
Partager