Working with recordsets

Discussion in 'Python' started by chema.rey@gmail.com, Jan 7, 2005.

  1. Guest

    Hi.

    I have one recorset that I would like to pass to 2 functions, one is
    for create an CSV file and the other one is to create a HTML file. The
    problem is that the recordset is totally read in the first function,
    and then when I pass it to the second funtion the recordset is in the
    last record.

    I've read docs, but I think that one cursor doesn't have something
    like movefirst() method. Anybody have an idea to solve this?

    Thank's.
    , Jan 7, 2005
    #1
    1. Advertising

  2. AdSR Guest

    wrote:
    > Hi.
    >
    > I have one recorset that I would like to pass to 2 functions, one is
    > for create an CSV file and the other one is to create a HTML file. The
    > problem is that the recordset is totally read in the first function,
    > and then when I pass it to the second funtion the recordset is in the
    > last record.
    >
    > I've read docs, but I think that one cursor doesn't have something
    > like movefirst() method. Anybody have an idea to solve this?
    >
    > Thank's.
    >


    Try loading the whole recordset with the fetchall() method and use the
    resulting sequence in your functions. It won't be memory-efficient but
    it will be easy to do.

    AdSR
    AdSR, Jan 7, 2005
    #2
    1. Advertising

  3. Steve Holden Guest

    AdSR wrote:

    > wrote:
    >
    >> Hi.
    >>
    >> I have one recorset that I would like to pass to 2 functions, one is
    >> for create an CSV file and the other one is to create a HTML file. The
    >> problem is that the recordset is totally read in the first function,
    >> and then when I pass it to the second funtion the recordset is in the
    >> last record.
    >>
    >> I've read docs, but I think that one cursor doesn't have something
    >> like movefirst() method. Anybody have an idea to solve this?
    >>
    >> Thank's.
    >>

    >
    > Try loading the whole recordset with the fetchall() method and use the
    > resulting sequence in your functions. It won't be memory-efficient but
    > it will be easy to do.
    >
    > AdSR


    Or, if this doesn't suit, try creating two separate cursors from the
    same connection and execute the same query on each. There's some chance
    that your database driver/backend combination will optimize the queries
    then.

    regards
    Steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
    Steve Holden, Jan 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AFN
    Replies:
    5
    Views:
    406
    dilipdotnet at apdiya.com
    Feb 11, 2004
  2. Sky
    Replies:
    2
    Views:
    365
  3. Guy Cohen

    ADO+RECORDSETS

    Guy Cohen, Jan 18, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    370
    sloan
    Jan 19, 2007
  4. Bob
    Replies:
    3
    Views:
    471
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 22, 2007
  5. Bob
    Replies:
    0
    Views:
    422
Loading...

Share This Page