jeudi 2 juillet 2015

How to move to and from an on-disk database to in-memory database

In :memory: option gives speedier queries and updates than the equivalent on-disk database. How can I load a disk-based database into memory, do fast operations on it and then write it back to disk.

The question How to browse an in memory sqlite database in python seems related but it focuses on how to use a disk-based browsing tool on an in-memory db. The question at How can I copy an in-memory SQLite database to another in-memory SQLite database in Python? is also related but it is specific to Django.

My current solution is to read all of the tables, one-at-a-time from the disk-based database into lists of tuples, then I manually recreate the entire database schema for the in-memory db, and then load the data from the lists of tuples into the in-memory db. After operating on the data, the process is reversed.

There must be a better way!

Aucun commentaire:

Enregistrer un commentaire