func (self *KcDb) Close() error { defer C.kcdbdel(self.cdb) if C.kcdbclose(self.cdb) == kcFalse { return errors.New(fmt.Sprintf("close: %s", C.GoString(C.kcecodename(C.kcdbecode(self.cdb))))) } return nil }
func OpenKcDb(dbFile string) (*KcDb, error) { db := new(KcDb) cdb := C.kcdbnew() cDbFile := C.CString(dbFile + "#type=kch#opts=c#zcomp=lzma#msiz=536870912") defer C.free(unsafe.Pointer(cDbFile)) if C.kcdbopen(cdb, cDbFile, C.KCOWRITER|C.KCOCREATE|C.KCOTRYLOCK) == kcFalse { errCode := C.kcdbecode(cdb) return nil, errors.New(fmt.Sprintf("open: %s", C.GoString(C.kcecodename(errCode)))) } db.cdb = cdb return db, nil }
// Returns a readable string to the last occurred error in the database func (d *DB) LastError() string { errMsg := C.GoString(C.kcecodename(C.kcdbecode(d.db))) return errMsg }
func (kc *KCDB) Ecode() int { return int(C.kcdbecode(kc.db)) }
// LastError returns a KCError instance representing the last occurred error in // the database. func (d *DB) LastError() error { errMsg := C.GoString(C.kcecodename(C.kcdbecode(d.db))) return KCError(errMsg) }