Too slow to read an entire table from Microsoft Access

L

lialie

Hi, all:
I read a table with 4500 rows and 12 columns using win32com.client.
Reading and updating records are OK, but cost too much time.Especially
making a dict as line(***).
All follows done may take nearly 90s!
Is there any good idea? Thanks.

conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN='Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='+DB_FILE_PATH+';Persist Security Info=False;'
conn.Open(DSN)
record_set = win32com.client.Dispatch(r'ADODB.Recordset')
record_set.Open('[Detail]', conn, 1, 3)
record_set.MoveFirst()

while not record_set.EOF:
tmp = ((record_set.Fields(i).Name, record_set.Fields.Item(i).Value)
for i in range(record_set.Fields.count))
print dict(tmp)
-----------------------------------------------------------------(***)
record_set.MoveNext()
 
F

fumanchu

I read a table with 4500 rows and 12 columns using win32com.client.
Reading and updating records are OK, but cost too much time.Especially
making a dict as line(***).
All follows done may take nearly 90s!
Is there any good idea? Thanks.

Yeah:

1. Don't use MoveFirst/MoveNext to read. Use GetRows. It's about 60%
faster (on average) in my experience:
http://projects.amor.org/dejavu/browser/trunk/storage/storeado.py?rev=335#l593

2. Unwind as much of each win32com call as you can, and try to call
InvokeTypes directly. That'll save you another big chunk. See
http://projects.amor.org/dejavu/browser/branches/1.5/storage/storeado.py#l700


Robert Brewer
System Architect
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top