'bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)
Open database name in the dbhome Berkeley DB directory.
Use keyword arguments when calling this constructor.'

def __init__(self, filename, dbhome, create=0, truncate=0, mode=384, recover=0, dbflags=0):

    self.db = None
    myflags = db.DB_THREAD
    if create:
        myflags |= db.DB_CREATE
    flagsforenv = ((((db.DB_INIT_MPOOL | db.DB_INIT_LOCK) | db.DB_INIT_LOG) | db.DB_INIT_TXN) | dbflags)
    try:
        dbflags |= db.DB_AUTO_COMMIT
    except AttributeError:
        pass
    if recover:
        flagsforenv = (flagsforenv | db.DB_RECOVER)
    self.env = db.DBEnv()
    self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
    self.env.open(dbhome, (myflags | flagsforenv))
    if truncate:
        myflags |= db.DB_TRUNCATE
    self.db = db.DB(self.env)
    self.db.set_get_returns_none(1)
    self.db.set_flags(db.DB_DUP)
    self.db.open(filename, db.DB_BTREE, (dbflags | myflags), mode)
    self.dbfilename = filename
    if (sys.version_info[0] >= 3):
        class cursor_py3k(object, ):
            def __init__(self, dbcursor):
                self._dbcursor = dbcursor
            def close(self):
                return self._dbcursor.close()
            def set_range(self, search):
                v = self._dbcursor.set_range(bytes(search, 'iso8859-1'))
                if (v is not None):
                    v = (v[0].decode('iso8859-1'), v[1].decode('iso8859-1'))
                return v
            def __next__(self):
                v = getattr(self._dbcursor, 'next')()
                if (v is not None):
                    v = (v[0].decode('iso8859-1'), v[1].decode('iso8859-1'))
                return v
        class db_py3k(object, ):
            def __init__(self, db):
                self._db = db
            def cursor(self, txn=None):
                return cursor_py3k(self._db.cursor(txn=txn))
            def has_key(self, key, txn=None):
                return getattr(self._db, 'has_key')(bytes(key, 'iso8859-1'), txn=txn)
            def put(self, key, value, flags=0, txn=None):
                key = bytes(key, 'iso8859-1')
                if (value is not None):
                    value = bytes(value, 'iso8859-1')
                return self._db.put(key, value, flags=flags, txn=txn)
            def put_bytes(self, key, value, txn=None):
                key = bytes(key, 'iso8859-1')
                return self._db.put(key, value, txn=txn)
            def get(self, key, txn=None, flags=0):
                key = bytes(key, 'iso8859-1')
                v = self._db.get(key, txn=txn, flags=flags)
                if (v is not None):
                    v = v.decode('iso8859-1')
                return v
            def get_bytes(self, key, txn=None, flags=0):
                key = bytes(key, 'iso8859-1')
                return self._db.get(key, txn=txn, flags=flags)
            def delete(self, key, txn=None):
                key = bytes(key, 'iso8859-1')
                return self._db.delete(key, txn=txn)
            def close(self):
                return self._db.close()
        self.db = db_py3k(self.db)
    txn = self.env.txn_begin()
    try:
        if (not getattr(self.db, 'has_key')(_table_names_key, txn)):
            getattr(self.db, 'put_bytes', self.db.put)(_table_names_key, pickle.dumps([], 1), txn=txn)
    except:
        txn.abort()
        raise
    else:
        txn.commit()
    self.__tablecolumns = {}
    return
