win32com and ADO

C

Chris Curvey

I'm having one of those weeks.

I have this pattern all over my code.

result = conn.execute("select * from foo")

while not result.EOF:
doSomething()
result.MoveNext()

So recently I got around to running makepy on all of the Microsoft
ActiveX Data Objects, and now every call to that pattern is returning:

'tuple' object has no attribute EOF

can anyone tell me how I'm supposed to be using EOF?

can anyone point me to the file that has the function lists?

can anyone tell me how to undo what I've done?
 
P

Peter Hansen

Chris said:
I'm having one of those weeks.

I have this pattern all over my code.

result = conn.execute("select * from foo")

while not result.EOF:
doSomething()
result.MoveNext()

So recently I got around to running makepy on all of the Microsoft
ActiveX Data Objects, and now every call to that pattern is returning:

'tuple' object has no attribute EOF

can anyone tell me how I'm supposed to be using EOF?

There are case sensitivity differences with and without makepy. I think
after makepy you have to respect the case of all names, so check for Eof
or eof or something.
can anyone point me to the file that has the function lists?

can anyone tell me how to undo what I've done?

Remove the files created by makepy. I forget where they exist but
they're not hard to find (check the makepy source if nothing else).

-Peter
 
A

Achim Domma (Procoders)

Chris said:
result = conn.execute("select * from foo")

while not result.EOF:
doSomething()
result.MoveNext()

'tuple' object has no attribute EOF

The recordset you are looking for is a element of the tuple. Out of my
head I would say it's element 1, so you have to write:

result = conn.execute("select * from foo")[1]

regards,
Achim
 
C

Chris Curvey

Thanks Peter.

I found the files that makepy generated (in
$PYTHON_HOME/Lib/site-packages/win32com/gen_py). I've tried deleting
the individual files, and the entire directory, and I'm still getting
the error. (Maybe something was changed in the registry?)

[Fun side note -- after deleting the files, I thought I would look in
them for the EOF, but they stubbornly refused to regenerate, giving an
error about "This file has already been processed". The only way I
could regenerate the files was by deleting the win32com package via the
control panel and re-installing.]

In the generated files, I did find a reference to "EOF" (all caps) in
something called _prop_map_get_. (I had tried a few different
variations on Eof, but none of them worked.)

At this point, the only way that I can get to the EOF property is to
force the dynamic dispatch by importing from com.win32.client.dynamic,
AND coding like this:

rs = Dispatch("ADODB.RecordSet")
rs.ActiveConnection = conn
rs.Open("select * from foo")
while not rs.EOF:
doSomething()
rs.MoveNext()

I hope someone can lend me a clue before I edit all of these query
instances...
 
C

Chris Curvey

Achim,

Bingo. The recordset is in item 0. And that appears to work even on
systems where makepy has not been run.

Thanks so much.
 
P

Peter Hansen

Chris said:
Achim,

Bingo. The recordset is in item 0. And that appears to work even on
systems where makepy has not been run.

Thanks so much.

So was this not really something that was working *before* you ran
makepy, or is there still an unsolved mystery there?
 
C

Chris Curvey

it was working fine before running makepy, once I ran makepy, I had to
add the array index to make it work.
 

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
474,239
Messages
2,571,199
Members
47,834
Latest member
KristianEn

Latest Threads

Top