You will have to use the low level c api:
sqlite3_last_insert_rowid
sqlite3_prepare
sqlite3_step
Does this translate to: for my purpose TSQLite3Dataset cannot be used?
<<update>>
'Manually' calling all sqlite functions (sqlite3_open(), sqlite3_prepare() etc...) combined with a sqlite3 transaction gives the result I was looking for: approx. 25.000 inserts in a second and the correct ID's returned after each insert.
Now I only need to write a Lazarus wrapper class...
Beside this you may want to use GUID as PK to avoid such round trip as tiOPF does
I need several tens of thousands of records; so the 64 bit resolution in SQLite's autoincrement PK's should be sufficient for my purposes.
<<update2>>
Final words: a working solution is using TSqlite3Dataset and manually specifying the dml
within a transaction. So no need to re-invent the wheel.
The code below gives me the >20K inserts per second.
//...
ds.ExecSQL('BEGIN TRANSACTION');
ds.ExecSQL('INSERT....'); ProcessID( ds.LastInsertRowId );
ds.ExecSQL('INSERT....'); ProcessID( ds.LastInsertRowId );
//....
ds.ExecSQL('COMMIT');