mysql connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Python_it

    #1

    mysql connection

    How can I close more cursors at the END of my page,
    after execute some scripts/functions.

    example:
    I use one DB connection and 5 cursor actions.

    How can I close these connections/actions at the END of my page?


    cursor.close() ==> 5 times??
    db.close()

  • Steve Holden

    #2
    Re: mysql connection

    Python_it wrote:[color=blue]
    > How can I close more cursors at the END of my page,
    > after execute some scripts/functions.
    >
    > example:
    > I use one DB connection and 5 cursor actions.
    >
    > How can I close these connections/actions at the END of my page?
    >
    >
    > cursor.close() ==> 5 times??
    > db.close()
    >[/color]
    If the five cursor actions are all performed on the same cursor then you
    only need one cursor.close().

    Of course you may also need to delete (or otherwise make available for
    garbage collection) the results you have fetched with cursor.fetchall ()
    and similar methods, but basically you just need to close each cursor
    you open once.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC www.holdenweb.com
    PyCon TX 2006 www.python.org/pycon/

    Comment

    • Steve Holden

      #3
      Re: mysql connection

      Python_it wrote:[color=blue]
      > How can I close more cursors at the END of my page,
      > after execute some scripts/functions.
      >
      > example:
      > I use one DB connection and 5 cursor actions.
      >
      > How can I close these connections/actions at the END of my page?
      >
      >
      > cursor.close() ==> 5 times??
      > db.close()
      >[/color]
      If the five cursor actions are all performed on the same cursor then you
      only need one cursor.close().

      Of course you may also need to delete (or otherwise make available for
      garbage collection) the results you have fetched with cursor.fetchall ()
      and similar methods, but basically you just need to close each cursor
      you open once.

      regards
      Steve
      --
      Steve Holden +44 150 684 7255 +1 800 494 3119
      Holden Web LLC www.holdenweb.com
      PyCon TX 2006 www.python.org/pycon/

      Comment

      Working...