Storing pairs of (int,int) in a database : which db to choose ?

Gabriel Genellina gagenellina at softlab.com.ar
Wed Dec 24 13:49:15 EST 2003


At 23/12/2003 04:35, you wrote:

>I want to implement a fulltext search for messages in a forum. More
>exactly for each message I store pairs (wordId, msgId) for each
>identified word and when I search something I want to be able to
>retrieve very quickly all msgId for a given wordId.
>
>So my problem now is what should I use to store my data and still be
>able to retrieve all messages for a given word very quickly. Either I
>find a workaround in sqlite to make it store values on less bytes, or
>I use something else.

Try the shelve module: it comes with Python, it's like a persistent 
dictionary whith key=string, value=anything. Uses dbm and pickle internally.
Instead of storing pairs, you could store:
         wordId: (tuple of msgIds)
so your primary search is just like a dictionary lookup: db[wordId]


Gabriel Genellina
Softlab SRL






More information about the Python-list mailing list