Newbie question - deleting records from anydbm database

D

Dan M

I've been Googling like a mad fiend and flipping through my hard-copy
Python books, but still haven't located the one little bit of info I need.

I've put together a simple SMTP-after-IMAP script that gets the authorized
IP info from the mail log (I know, it's not elegant but it works). All
works fine up until I go to scan the database of added IP addresses to
delete the old ones. The problem is, I don't know how to drop a record
from an anydbm database!

The database file in question is compatible with the database built using
"makemap hash imapauth < imapauth" - in fact, I'm using makemap to check
the file contents against what I'm expecting.

I'm adding records with code such as:
db = anydbm.open(accessDbPath, "w")
db[ipAddress] = str(time.time())

Now how can I go about deleting that record when it's too old?
 
S

Steve Holden

Dan said:
I've been Googling like a mad fiend and flipping through my hard-copy
Python books, but still haven't located the one little bit of info I need.

I've put together a simple SMTP-after-IMAP script that gets the authorized
IP info from the mail log (I know, it's not elegant but it works). All
works fine up until I go to scan the database of added IP addresses to
delete the old ones. The problem is, I don't know how to drop a record
from an anydbm database!

The database file in question is compatible with the database built using
"makemap hash imapauth < imapauth" - in fact, I'm using makemap to check
the file contents against what I'm expecting.

I'm adding records with code such as:
db = anydbm.open(accessDbPath, "w")
db[ipAddress] = str(time.time())

Now how can I go about deleting that record when it's too old?
(untested)

try

del db[ipAddress]

regards
Steve
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top