예제 #1
0
 def home(self):
     home = self._connection[0].get_home(self._connection[0])
     home = ffi.string(home).decode('utf-8')
     return home
예제 #2
0
def check(code, ret=None):
    if code == 0:
        return ret
    else:
        msg = ffi.string(lib.wiredtiger_strerror(code))
        raise WiredtigerException(msg.decode('utf-8'))
예제 #3
0
 def _key_format(self):
     return ffi.string(self._cursor[0].key_format).decode('utf-8')
예제 #4
0
 def _value_format(self):
     return ffi.string(self._cursor[0].value_format).decode('utf-8')
예제 #5
0
    'S': lambda x: ffi.new('char[]', x.encode('utf-8')),
    'Q': lambda x: ffi.cast('uint64_t', x),
    'q': lambda x: ffi.cast('int64_t', x),
    'u': make_item
}

INIT_CDATA = {
    'S': lambda: ffi.new('char **'),
    'Q': lambda: ffi.new('uint64_t *'),
    'q': lambda: ffi.new('int64_t *'),
    'u': lambda: ffi.new('WT_ITEM *'),
    'U': lambda: ffi.new('WT_ITEM *'),
}

FROM_CDATA = {
    'S': lambda x: ffi.string(x[0]).decode('utf-8'),
    'Q': lambda x: x[0],
    'q': lambda x: x[0],
    'u': lambda x: ffi.string(ffi.cast('char *', x[0].data), x[0].size),
    'U': lambda x: ffi.string(ffi.cast('char *', x[0].data), x[0].size)
}


class Cursor:

    def __init__(self, cursor):
        self._cursor = cursor
        self.__unset_ptr()

    def _key_format(self):
        return ffi.string(self._cursor[0].key_format).decode('utf-8')