coldpizza wrote: >Hi, > >I want to run a database query and then display the first 10 records >on a web page. Then I want to be able to click the 'Next' link on the >page to show the next 10 records, and so on. > >My question is how to implement paging, i.e. the 'Next/Prev' NN >records without reestablishing a database connection every time I >click Next/Prev? Is it at all possible with cgi/mod_python? > >For example, in a NON-web environment, with sqlite3 and most other >modules, I can establish a database connection once, get a cursor >object on which I run a single 'SELECT * FROM TABLE' statement and >then use cursor.fetchmany(NN) as many times as there are still results >left from the initial query. > >How do I do the same for the web? I am not using any high-level >framework. I am looking for a solution at the level of cgi or >mod_python (Python Server Pages under Apache). To call >cursor.fetchmany(NN) over and over I need to pass a handle to the >database connection but how do I keep a reference to the cursor object >across pages? I use mysql and sqlite3 as databases, and I am looking >for an approach that would work with both database types (one at a >time). So far I have successfully used the following modules for >database access: sqlite3, mysqld, and pyodbc. > > Apache/cgi just dont work this way. When apache receives a new request (a cgi being called), it starts a new thread, it execute him, and gives the client some result. AND THEN KILL THE THREAD. Altough i never used it, what i think you need is fast cgi (fcgi), wich takes care of persistent connections to a web server.
Cheers. Gerardo -- http://mail.python.org/mailman/listinfo/python-list