Any way to access db5 data with python?
Milan Obuch
freebsd-python at dino.sk
Fri Jun 19 14:01:28 UTC 2020
Hi,
I am trying to upgrade mail/courier-pythonfilter port to new version
using Python 3. While it basically works, I found there is some problem
accessing database from courier mail server. In log file I see
courierfilter[2875]: Error reading /usr/local/etc/courier/smtpaccess.dat
This file exists, it is
-rw-r--r-- 1 root courier 131072 May 26 13:30 smtpaccess.dat
Pythonfilter author wrote me it probably means there is no module for
accessing it and suggested test
$ python3
>>> import dbm
>>> dbm.open('/usr/local/etc/courier/smtpaccess.dat', 'r')
This gives an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dbm/__init__.py", line 88, in open
raise error[0]("db type could not be determined")
dbm.error: db type could not be determined
With some tests I found a way to display file contents:
# dbmmanage /usr/local/etc/courier/smtpaccess.dat view
127.0.0.1:allow,RELAYCLIENT
:0000:0000:0000:0000:0000:0000:0000:0001:allow,RELAYCLIENT
10:allow,RELAYCLIENT
192.168:allow,RELAYCLIENT
or
# db_dump185-5.3 -p /usr/local/etc/courier/smtpaccess.dat
format=print
type=hash
h_ffactor=65536
db_lorder=1234
db_pagesize=32768
HEADER=END
127.0.0.1
allow,RELAYCLIENT
:0000:0000:0000:0000:0000:0000:0000:0001
allow,RELAYCLIENT
10
allow,RELAYCLIENT
192.168
allow,RELAYCLIENT
First one uses binary installed with apache web server, second one uses
binary from db5 package.
One more test:
# file /usr/local/etc/courier/smtpaccess.dat
/usr/local/etc/courier/smtpaccess.dat: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Could anybody offer a hint? I found no Python package for db5, at least
not with name like py-db5 or some such tricial.
Regards,
Milan
More information about the freebsd-python
mailing list