odbc advice?

Steve Holden sholden at holdenweb.com
Fri May 10 08:08:32 EDT 2002


"don" <donald.braman at yale.edu> wrote ...
> Sorry, I should have included the rest:
>
>         conn = odbc.odbc('mybase')
>         cur = conn.cursor()
>         cur.execute("""UPDATE Cases SET Cases.Opinion = NULL WHERE
> updateopinion=1""")
>         conn.commit()
>         cur.close()
>         conn.close()
>
> I'll try it with
>         cur = NONE
> at the end as well & see what happens.
>
> Thanks for the tip! -Don
>
> "William Dode" <wilk at flibuste.net> wrote in message
> news:20020509234009.49430be6.wilk at flibuste.net...
> > Le Thu, 9 May 2002 13:11:48 -0700
> > "don" <donald.braman at yale.edu> écrivait:
> >
> > > I'm trying to update table in a SQL Server 2000 database. The
following
> > > (and other similar) code hangs Python about half of the time when I
run
> > > it and then, once hung, will hang every time until I reboot. Does
anyone
> > > have any tips on handling odbc connections in Python? I've been
hunting
> > > around for a while, but haven't found descriptions of hangs like this.
> > > My reference of choice (Python Web Programming) tells me the ODBC
driver
> > > isn't ready for prime-time. I'm not sure I have any other options,
> > > though. Any help appreciated. -Don
> > >
> > > ++++++++++++++++++++++++
> > >
> > > import dbi, odbc
> > >
> > > conn = odbc.odbc('mydb')
> > >
> > > cur = conn.cursor()
> > >
> > > cur.execute("""UPDATE Cases SET Cases.Opinion = NULL WHERE
> > > updateopinion=1""")
> > did you try to add
> >
> > cur.commit()
> > cur.close()
> > cur=None
> >

I'm afraid the

    cur = NONE

will fail with a NameError, as it should be

    cur = None

Furthermore, I regret that this is superstition, probably from someone who
(like me) has been bitten in the ass by ASP's complete failure to manage
memory correctly. In the VBScript ASP environment it's possible to leak
memory by retaining object references at the end of a page. In Python (I
believe) the references will all be automatically garbage-collected, so that
alone isn't going to make a non-functional program work.

Such is my understanding, anyway.

it-surely-won't-hurt-though-ly y'rs  - steve
--
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list