0

I'm new to datatables and javascript. I'm using nodejs and oracledb. I have more than 2 million data in a table, it's not loading on the page so I set a 5000 row limit:

SELECT * FROM DATA_TABLE WHERE ROWNUM < 5000

Here is the sample datatable

I want to export all data in csv format but now I have 5000 row limit. Can I change the source of the .csv button's data? How can I do this? Is there any other way to do this?

I tried Server-side processing and fetching it with ajax but it didn't work or I couldn't. Can I use Fetch API instead of ajax here?

$('#example').DataTable({
    processing: true,
    serverSide: true,
    ajax: '/data-source',
});
Faruk
  • 1
  • 3
    So, you have a client web page using jQuery & DataTables and a backend Node.js webapp, and you want the client to be able to download a CSV of the entire database from the backend? Why not implement an API route on the backend that exports the data to CSV then compresses that and returns it to the client or, if too big for that, places it somewhere and provides the client with a response that allows the client to go and fetch it? – jarmod Apr 04 '23 at 21:39
  • Related: [see here](https://stackoverflow.com/a/75229058/12567365). Bottom line: it can be attempted, but I think you should really use a server-side export tool, instead. – andrewJames Apr 04 '23 at 22:01
  • I agree the API method is the way to go. Or run node.js on the computer you want the CSV to be on and don't have any Web components - just read from the DB and write to the disk. Regardless of architecture, don't forget to tune `fetchArraySize`, see https://node-oracledb.readthedocs.io/en/latest/user_guide/tuning.html#choosing-values-for-fetcharraysize-and-prefetchrows. – Christopher Jones Apr 04 '23 at 22:36
  • thanks for all comments, @andrewJames the link you posted seems to useful, if i can not find any other solution i will try this, thanks. – Faruk Apr 25 '23 at 13:25
  • @ChristopherJones thanks for reminding me to set fetchArraySize – Faruk Apr 25 '23 at 13:27
  • @jarmod i tried this but i haven't succeeded yet, i keep working on it – Faruk Apr 25 '23 at 13:29

0 Answers0