This schema seems to work (I did a 10-element buffer instead of 1000):
CREATE TABLE Buffer (Value);
CREATE TABLE BufferIndex (I);
CREATE TRIGGER BufferIncr BEFORE INSERT ON Buffer
FOR EACH ROW BEGIN
UPDATE BufferIndex SET I = ((SELECT I from BufferIndex)+1)%10;
END;
INSERT INTO BufferIndex (I) VALUES (-1) -- Initial index is -1
Then insert data (the current time in this example) into the buffer with:
INSERT OR REPLACE INTO Buffer (rowID, Value) Values ((SELECT I FROM BufferIndex),time('now'))
The Trigger serves to increment the index before the INSERT.
To get the ordered elements one can use a View:
CREATE VIEW OrderedBuffer AS
SELECT Value FROM Buffer,BufferIndex WHERE Buffer.rowID>I
UNION ALL
SELECT Value FROM Buffer,BufferIndex WHERE Buffer.rowID<=I;