def primitiveSQLNextObject(interp, s_frame, w_rcvr, cursor_handle): if CConfig is None: raise PrimitiveFailedError('sqpyte not found') space = interp.space cursor = dbm.cursor(cursor_handle) row = cursor.raw_next(space) if not row: return space.w_nil w_id = None num_cols = len(row) cache = [None] * num_cols for i in range(num_cols): name = cursor.column_names[i] if name == 'id': w_id = row[i] else: n0 = int(name[9:]) # strip 'inst_var_' class_name = w_rcvr.classname(interp.space).split(' ')[0] if W_DBObject.state.get_column_type(class_name, n0) is BLOB: db_id = space.unwrap_int(row[i]) cache[n0] = W_DBObject.state.db_objects[db_id] else: cache[n0] = row[i] if w_id is None: raise PrimitiveFailedError('Could not find w_id') return W_DBObject(space, w_rcvr, num_cols, w_id=w_id, cache=cache)
def primitiveSQLColumnName(interp, s_frame, w_rcvr, cursor_handle, index): if index < 1: raise PrimitiveFailedError('Index must be >= 1') # Smalltalk counts from 1, rest of world from 0 return interp.space.wrap_string( dbm.cursor(cursor_handle).column_names[index - 1])
def primitiveSQLColumnNames(interp, s_frame, w_rcvr, cursor_handle): return interp.space.wrap_list([ interp.space.wrap_string(c) for c in dbm.cursor(cursor_handle).column_names])
def primitiveSQLColumnCount(interp, s_frame, w_rcvr, cursor_handle): return interp.space.wrap_int(dbm.cursor(cursor_handle).column_count)
def primitiveSQLNext(interp, s_frame, w_rcvr, cursor_handle): return dbm.cursor(cursor_handle).next(interp.space)