Pysqlite tables in RAM

John Machin sjmachin at lexicon.net
Fri Oct 6 02:43:10 EDT 2006


Ranjitha wrote:
> Fredrik Lundh wrote:
>
> > Ranjitha wrote:
> >
> > > I want to store my data in a database on the disk. I also want to be
> > > able to reload the tables into the RAM whenever I have a lot of disk
> > > accesses and commit the changes back to the database.
> >
> > using the cache_size and synchronous pragmas sounds like a better way to
> > trade reliability against speed/memory use.  e.g.
> >
> > table_memory = 100000000 # bytes
> > cur.execute("pragma cache_size = %d;" % (table_memory / 1500))
> >
> > ...
> >
> > cur.execute("pragma synchronous = off;")
> > # do lots of stuff
> > cur.execute("pragma synchronous = full;")
> >
> > for more on this, see: http://www.sqlite.org/pragma.html
> >
> > </F>
>
> Thanks a lot for the help but could you please elaborate on this. I'm
> finding it difficult to follow the link you sent me. The jargon seems
> all too new for me.
>

For a start, you don't need to read the whole page, just the sections
on "cache_size" [the more memory in the cache, the faster it will run
-- up to a point, which you could experiment  with] and "synchronous"
[off = faster/dangerous, on = slower/safer].

It would help greatly if you said which particular words or phrases you
don't understand, plus give an assurance that you have made *some*
effort to help yourself e.g. googled the puzzling words/phrases  ...

Have you actually tried doing what Fredrik suggested?




More information about the Python-list mailing list