I am beginar in python script. I want read msaccess database records and write into XML file. Access database table have more than 20000 records.
Now i am able to do but , it is taking 4 to 5 minutes. So i implement threading concept. But threading also taking more than 5 to 6 minutes. Because each thread open datasource reading records from tables and close datasource.
I don't know how to solve the problems.
CODE:
class ConfigDataHandler(Thread):
def __init__(self, dev):
Thread.__init__(self)
self.dev = dev
def run(self):
db_source_path = r'D:\sampleDB.mdb'
db_source = win32com.client.Dispatch(r'ADODB.Connection')
db_source.ConnectionString = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;
DATA SOURCE=' + db_source_path + ';'
db_source.Open()
query = """ SELECT * from table"""
source_rs = win32com.client.Dispatch(r'ADODB.Recordset')
source_rs.Open(query, db_source, 3, 1)
while not source_rs.EOF :
f_units.append(source_rs.fields("Name").Value))
source_rs.MoveNext()
source_rs.Close()
db_source.Close()
out = render(f_units)
open("D:/test.xml", "w").write(out)
d_list = get_dev_list()
for d in d_list:
current = ConfigDataHandler(d)
current.start()