python - access search from XML file -
my code make search in xml file ( function "findterminal") specific attribute name , pass other function ( called dbaccess) find attribut in access database . attribute name not concatenated in database, had make comparison. buut nothing happend when execute code ?
import csv import pyodbc xml.dom import minidom # ************************************* def dbaccess (term): mdb = 'c:/test/mydb.mdb' drv = '{microsoft access driver (*.mdb)}' pwd = '' conn = pyodbc.connect('driver=%s;dbq=%s;pwd=%s' % (drv,mdb,pwd)) curs = conn.cursor() print 'connexion opened' sql = 'select * gdo_arc;' # insert query here curs.execute(sql) curs.execute("select nat_arc gdo_segment") rows = curs.fetchall() row in rows: t = 't' + row.tronson + '_' + row.noued1 + '-' + row.noued2 if t == term : print (' terminal found') curs.close() conn.close() #************************************* def findterminal(): xmldoc = minidom.parse('c:\\test\mydoc.xml') #printing number of blocs in xml file itemlist = xmldoc.getelementsbytagname('aclinesegment') item in itemlist: found = false child in item.childnodes: if child.nodename == 'terminal': found = true if not found: term = item.getattribute('name') dbaccess (term) #*********************************** findterminal()
Comments
Post a Comment