berkeley db delete problem?

O

Oliver Peek

Hi all,

Probably my fault, I'm opening a Berkeley DB
file, iterating through and deleting keys, well
making an attempt. I get this error when I try
to delete.

---error
Traceback (most recent call last):
File "./db.py", line 41, in ?
db.delete()
AttributeError: delete
---end error

Below is a code snippet:
---code
#!/usr/bin/python

import bsddb

db = bsddb.btopen('./test.db', 'r')

rec = db.first()
while rec:
key, val = rec
db.delete()
rec = db.next()

db.close()
---end code

I have full code that opens and goes through and
prints the key and value and opens another db
file and inserts the key/data into that new db
file, but I need to delete the data out of the
master db file once it's been updated in the
smaller ones.

I've also tried db.delete(key) with no luck,
db.del(), db.del(key), db[key]='', and lots of
other silly attempts, but nothing works.

Thanks,
Oliver

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 
W

wes weston

Oliver said:
Hi all,

Probably my fault, I'm opening a Berkeley DB
file, iterating through and deleting keys, well
making an attempt. I get this error when I try
to delete.

---error
Traceback (most recent call last):
File "./db.py", line 41, in ?
db.delete()
AttributeError: delete
---end error

Below is a code snippet:
---code
#!/usr/bin/python

import bsddb

db = bsddb.btopen('./test.db', 'r')

rec = db.first()
while rec:
key, val = rec
db.delete()
rec = db.next()

db.close()
---end code

I have full code that opens and goes through and
prints the key and value and opens another db
file and inserts the key/data into that new db
file, but I need to delete the data out of the
master db file once it's been updated in the
smaller ones.

I've also tried db.delete(key) with no luck,
db.del(), db.del(key), db[key]='', and lots of
other silly attempts, but nothing works.

Thanks,
Oliver

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Oliver,
Does clear() work?
wes
 
W

wes weston

Oliver said:
Hi all,

Probably my fault, I'm opening a Berkeley DB
file, iterating through and deleting keys, well
making an attempt. I get this error when I try
to delete.

---error
Traceback (most recent call last):
File "./db.py", line 41, in ?
db.delete()
AttributeError: delete
---end error

Below is a code snippet:
---code
#!/usr/bin/python

import bsddb

db = bsddb.btopen('./test.db', 'r')

rec = db.first()
while rec:
key, val = rec
db.delete()
rec = db.next()

db.close()
---end code

I have full code that opens and goes through and
prints the key and value and opens another db
file and inserts the key/data into that new db
file, but I need to delete the data out of the
master db file once it's been updated in the
smaller ones.

I've also tried db.delete(key) with no luck,
db.del(), db.del(key), db[key]='', and lots of
other silly attempts, but nothing works.

Thanks,
Oliver

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Oliver,
How bout del db[key]
wes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top