This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: whichdb too dumb
Type: Stage:
Components: Extension Modules Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: dotysan, loewis
Priority: normal Keywords:

Created on 2006-08-29 05:51 by dotysan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg29699 - (view) Author: Curtis Doty (dotysan) Date: 2006-08-29 05:51
On my system with db4, I noticed that whichdb doesn't
know anything about more recent database types created
by the bsddb module.

Python 2.4.3 (#1, Jun 13 2006, 11:46:08) 
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> 
>>> from whichdb import *
>>> import bsddb
>>> 
>>> dbfile= "hash"
>>> bsddb.hashopen( dbfile)
{}
>>> whichdb( dbfile)
'dbhash'
>>> # yay
... 
>>> dbfile= "btree"
>>> bsddb.btopen( dbfile)
{}
>>> whichdb( dbfile)
''
>>> # bah
... 
>>> dbfile= "recno"
>>> bsddb.rnopen( dbfile)
{}
>>> whichdb( dbfile)
''
>>> # humbug!

It looks like both these database types share:

#define DB_BTREEMAGIC   0x053162

So this might be a start:

--- Python-2.5c1/Lib/whichdb.py.orig 2005-02-05
22:57:08.000000000 -0800
+++ Python-2.5c1/Lib/whichdb.py      2006-08-28
13:46:57.000000000 -0700
@@ -109,6 +109,10 @@
     if magic in (0x00061561, 0x61150600):
         return "dbhash"
 
+    # Check for binary tree
+    if magic == 0x00053162:
+        return "btree"
+
     # Unknown
     return ""
 

But alas, I'm not clear on the best way to
differentiate between btree and recno.

The above example is on 2.4 but persists in 2.5.
msg29700 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-09-10 00:08
Logged In: YES 
user_id=21627

It is not the job of whichdb to recognize certain database
types created by the bsddb module. Instead, as the doc
string says

"Guess which db package to use to open a db file."

The return value of whichdb is a *module name*. Since
"btree" is not a module name, the proposed change is incorrect.

Closing as invalid.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43908
2006-08-29 05:51:11dotysancreate