Why can't use cursor.nextset() in adodbapi package?

N

nightmarch

I want use crsr.nextset() , But I got errors like following:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\adodbapi\adodbapi.py", line 711,
in nextset
rsTuple=self.rs.NextRecordset()
File "<COMObject Execute>", line 2, in NextRecordset
File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py",
line 251, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3',
(0, 'ADODB.Recordset', 'Current provider does not support returning
multiple recordsets from a single execution.',
'C:\\WINNT\\HELP\\ADO210.CHM', 0, -2146825037), None)




Why?

thanks
 
D

Dennis Lee Bieber

com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3',
(0, 'ADODB.Recordset', 'Current provider does not support returning
multiple recordsets from a single execution.',
'C:\\WINNT\\HELP\\ADO210.CHM', 0, -2146825037), None)




Why?

Could it be because you don't have multiple recordsets in crsr?

You're executing a single select statement, retrieving the
/first/ record from the result, and then trying to get a totally
different result set.

Maybe you want the next record in the record set you already
have? crsr.fetchnext()?

--
 
N

nightmarch

Thank you Dennis!

You mean I should execute many select statement like this " rec =
crsr.fetchall() " ?
But the result is the same, still got the error like "... 'Current
provider does not support returning multiple recordsets from a single
execution.'..."
 
D

Dennis Lee Bieber

Thank you Dennis!

You mean I should execute many select statement like this " rec =
crsr.fetchall() " ?
But the result is the same, still got the error like "... 'Current
provider does not support returning multiple recordsets from a single
execution.'..."

Multiple recordsets, as I understand it, implies one execute
that returns more than one "select" structure (I'm very weak on
paraphrasing this).

Your SELECT should be returning multiple /records/ in ONE
recordset. It is the multiple records you should be processing. What
follows is an excerpt from a program I have that updates a static web
page (no CGI/dynamic server available -- I have to update the database
locally, run a Python script to regenerate the web page, and upload the
web page).

I execute a SELECT, the process /all/ the returned records using
a loop on fetchall(). {TableRow() is a short function that writes the
HTML for a table data row}

# open database NOTE: NO ERROR CHECKING
myDB = MySQLdb.connect(host='localhost', user='bestiaria',
passwd='web-asst', db='bestiaria')
myC = myDB.cursor()

# get convention records occurring later than today
myC.execute("""select name, URL, banner, width, height, dates,
site, notes
from conventions
where sortdate > curdate()
order by sortdate""")

# write each to table
for aCon in myC.fetchall():
(name, URL, banner, width, height, dates, site, notes) =
aCon
TableRow(fnew, name, URL, banner, width, height, dates,
site, notes)

# repeat for convention records occurring BEFORE today
myC.execute("""select name, URL, banner, width, height, dates,
site, notes
from conventions
where sortdate <= curdate()
order by sortdate""")

# write each to table
for aCon in myC.fetchall():
(name, URL, banner, width, height, dates, site, notes) =
aCon
TableRow(fnew, name, URL, banner, width, height, dates,
site, notes)


Oh, if it means anything, that uses a DB-API compatible module,
not some M$ specific system...

--
 
T

Tim Roberts

nightmarch said:
Thank you Dennis!

You mean I should execute many select statement like this " rec =
crsr.fetchall() " ?

No, you misunderstand. nextset() is used when you issue several SELECT
statements in a single request. The first fetchall() gets the results of
the first SELECT statement. To get the next one, you use nextset().

Your example only had one SELECT:

If you are only issuing one SELECT, like most applications, then nextset()
serves no purpose. If you did something like this:

sql = "select * from wjtmp; select count(*) from wjtmp;"

That's when you need nextset(). Personally, I've never used it.
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top