I have to create a Python script which connects to a MS-SQL DB (This is completed and extracting the information I need), and extracts a list of IP addresses from the table and use it to complete the server path to search an specific file on each server and then do modifications on 5 parameters on this file, then jump to next server and do the same changes and so on. Any help in the iteration creation will be more than welcome At the moment what I have so far is this:
import pyodbc
#### --->>>Connection to SQL Server
conn = pyodbc.connect('Driver={SQL Server};'
'Server=****Mi servidor****;'
'UID=***Usuario****;'
'PWD=***password***;'
'database=voiceData;'
'Trusted_Connection=yes;'
)
cursor = conn.cursor()
cursor.execute('EXECUTE dbo.GET_localOfficeAvayaFilePaths')
#### --->>>Changes on the 46xxsettings.txt file
for row in cursor:
print('', row[3])
string_map = {'## SET SLMSRVR': 'SET SLMSRVR 192.168.1.1',
'## SET SLMSTAT 1': 'SET SLMSTAT 1',
'## SET SLMPERF 1': 'SET SLMPERF 1',
'## SET SLMCAP 1': 'SET SLMCAP 2',
'SET SLMCTRL 1': 'SET SLMCTRL 1'}
for line in cursor.readlines():
if line.startswith('## SET'):
for original, new in string_map.items():
if original in line:
line = new
break
print(line.strip())
cursor.close()
del cursor