[pybsddb] Deleting a specific key/data pair in a database with duplicate keys

Will Weisser teetee at gmail.com
Sun Dec 7 01:28:48 CET 2008


To answer your question, I believe what you want to do is use a cursor and
either get_both() or use get() followed by next() to move to the item you
want, then call delete() to delete the item currently referenced by the
cursor.

However, Berkeley DB itself is very well supported on the Oracle technet
forums; I've asked some questions there and gotten prompt answers there from
sleepycat staff.

On Sat, Dec 6, 2008 at 5:28 PM, denis.papathanasiou at gmail.com <
denis.papathanasiou at gmail.com> wrote:

> This is more of a pure Berkeley DB question than a bsddb3 one, but the
> Berkeley mailing list is inactive, and I wondered whether or not anyone
> here would know the answer.
>
> I've created a database with duplicate keys by using
> DB.set_flags(db.DB_SUP | db.DB_DUPSORT) and it works as expected.
>
> While I can use DB.get_both() to pick out a specific key/data pair, is
> there an equivalent method to delete a specific key/value pair, leaving
> all the other values for the given key intact?
>
> DB.delete() will delete everything with a specific key, which is what I
> don't want.
>
> I also tried DB.get_both(key, value, None, db.DB_CONSUME), thinking that
> once get_both() picks out the specific key/value pair, DB_CONSUME will
> remove it, but the database complained that DB_CONSUME was an illegal
> flag for that method.
>
> Is there another way to do this?
> _______________________________________________
> pybsddb mailing list
> pybsddb at argo.es
> http://mailman.argo.es/listinfo/pybsddb
> http://www.argo.es/~jcea/programacion/pybsddb.htm<http://www.argo.es/%7Ejcea/programacion/pybsddb.htm>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.jcea.es/pipermail/pybsddb/attachments/20081206/1747a2d4/attachment.htm>


More information about the pybsddb mailing list