允许使用用1.8或1.10版创建的gdbm文件,无幻数错误。
gdbm_compat的Python项目详细描述
提供一种打开GDBM数据库的方法,否则会出现“错误的幻数”错误。
这在需要支持el6和el7(或centos 6和centos 7)时非常有用。
它支持打开用gdbm版本1.8或1.10创建的gdbm文件。有些功能可能在数据库上不起作用,但大多数都会起作用,这比没有要好!
主要的使用方法是使用“gdbm compat.open compat”代替“gdbm.open”。
例如:
>>> import gdbm_compat>>> ...>>> mydb = gdbm.open('mydatabase', 'r') # Database created on different system that wont openTraceback (most recent call last):
File “<stdin>”, line 1, in <module>
gdbm.error: Bad magic number
>>> mydb = gdbm_compat.open_compat('mydatabase.db', 'r') # Force it to open<;gdbm.gdbm对象位于0x7f7da47ee110>;
命令行接口
Usage: gdbm-compat-convert [-1.8/-1.10] [input filename] [output filename]
Changes the magic number on a gdbm database, to make it accessable on different platforms.支持更改为版本1.8或1.10,请将其作为第一个参数提供。
如果未提供“输出文件名”,则将以内联方式进行更改。
其他方法
还提供了一些其他方法。您可以在源发行版的doc/gdbm_compat.html中找到pydoc生成的文档。
许可证
gdbm_compat是在公共域下授权的。