database persistence with mysql, sqlite

Bryan Olson fakeaddress at nowhere.org
Wed Sep 26 03:28:39 EDT 2007


coldpizza wrote:
> It turned out that the method above ('SELECT * FROM TABLE LIMIT L1,
> L2') works ok both with mysql and sqlite3, therefore I have decided to
> stick with it until I find something better. With Sqlite3 you are
> supposed to use LIMIT 10 OFFSET NN, but it also apparently supports
> the mysql syntax (LIMIT NN, 10) for compatibility reasons.

A more reliable form is along the lines:

     SELECT keyfield, stuff
     FROM table
     WHERE keyfield > ?
     ORDER BY keyfield
     LIMIT 10

With the right index, it's efficient.


-- 
--Bryan



More information about the Python-list mailing list