Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python DBM Module for Windows?

I would like to use the dbm module on my Windows machine, but it is currently only supported on Unix. http://docs.python.org/library/dbm.html

Does anyone know of a similar module with similar syntax or a workaround to get dmb functional on windows? Being able to access a database written to the hard drive much like how I code to access a dictionary would be great. Thank you for your help!

like image 430
Brian Avatar asked Aug 04 '10 17:08

Brian


People also ask

What is Libgdbm?

GitHub - LuaDist/libgdbm: GNU dbm is a set of database routines that use extendible hashing and works similar to the standard UNIX dbm routines.


2 Answers

Actually, after more googling around, I found this:

http://docs.python.org/library/anydbm.html#module-anydbm

I've tried this on windows and it seems to be working fine =)

like image 113
Brian Avatar answered Oct 19 '22 16:10

Brian


Based on the following test on a Windows 7 system using Python 2.7.2 it appears that dbhash is supported on Windows instalations.

import os

import anydbm

import whichdb

file = os.curdir + '/testdbm'   # define a test file name in the current directory

d = anydbm.open(file, 'c')      # create a new database using the test file name

db_type = whichdb.whichdb(file) # get the dbm database type

print(db_type)                  # display the result

'dbhash'
like image 41
Steve Wood Avatar answered Oct 19 '22 14:10

Steve Wood