Everything the others said.
IMO, there are two ways around it WITHOUT recompiling sqlite3.dll,
1) is to use a "1:1-Extension"-table.
meaning:
You have Table1 with ID, Col1....Col1999, Table2 with ID, Col2000.....Col3999, Table3 with ID, Col4000...Col4999 (=5K Columns), with the caveat, that all ID's MUST be the same.
You could even declare the ID's in Table2 and Table3 as ForeignKey to Table1 including ON DELETE CASCADE
You'd need 3 Queries, since the SQLITE_MAX_COLUMN also limits the max count of Columns RETURNED by a Select.
That said: Create your BufDataset with your 5K Fields, run the first Query, and fill up the first 2K Columns of your BufDataset, run the second query, run the third query... etc.
2) Reorganize your Table to use JSON
Meaning: You have Table1 with ID and a single Column "MyJSON", and that JSON-Column contains the 5K Key/Values you'd have in separate columns.
When filling up your BufDataset, you'd have to "expand" the JSON-Values to its corresponding Field in the BufDataset.
Any MaxLength-Limit for such a JSON-Column not withstanding