three column dataset - additions and deletions

Tim Harig usernet at ilthio.net
Thu Dec 2 17:55:53 EST 2010


On 2010-12-02, draeath <draeath.spamtrap at gmail.com> wrote:
> The idea is that this script will run periodically, pulling the table, 
> and comparing the data gathered at that run to that stored by the 
> previous, acting on changes made, and storing the current data back (to 
> be referenced against in the next invocation)

So, basically, you want to store a local copy of the data and sync it to
the original.

> I figure it will be easy enough to determine changed hashes for a given 
> key. What I'm unclear on is what the best type of structure to keep this 
> data in, given that I need to modify the data after it comes in 
> (replacing that long string with, say, an MD5 from hashlib) and both need 
> to act on "new" rows (rows that don't exist in the 'old' data) and 
> deleted rows (rows that only exist in the 'old' data).

You need to differentiate between the in memory data model and the storage
model.  Since this data comes from a database in the first place, I would
dump it to an sqlite3 database from the beginning.  You can use this to
store, modify, and change the values as you receive them from the database.

If you are looking for in-memory structures, then you haven't really
provided us with enough information on the significance and organization of
the data.



More information about the Python-list mailing list