odbc cursor usage question

Victor Muslin victor at prodigy.net
Thu May 24 19:02:20 EDT 2001


Sorry for a newbie question, but I am not all that familar with ODBC.
I am using odbc,dbi modules that came with ActivePython 2.1 (build
201) for Windows platforms.

Am I supposed to allocate the cursor before each time before executing
a SQL statement?

	dbconn = odbc.odbc(cs)
	cur = dbconn.cursor()
	cur.execute(sql)
	resultset = cur.fetchall()
	cur.close()

When I try to reuse the cursor as follows:

	dbconn = odbc.odbc(cs)
	cur = dbconn.cursor()
	cur.execute(sql)
	resultset = cur.fetchall()
	cur.execute(sql2)
	resultset = cur.fetchall()
	cur.close()

Python crashes with a segment violation!!! Unfortunately, when I do
not reuse the cursor, there seems to be a memory leak. It appears that
the cursor object is not garbage collected.

Any suggestions would be REALLY appreciated :-)

TIA



More information about the Python-list mailing list