I want to read the contents of an SQL file in NodeJS. Is there a simple way to do this? Even just to import the whole file as a string somehow would be good. It seems like a basic thing but I can't find any information on how to do it.
Any help would be greatly appreciated.
CodePudding user response:
It turns out you can simply use
fs.readFileSync("file_name.sql").toString()
in the same manner you would a .txt file.
CodePudding user response:
you can try use XMLHttpRequest to import the file as a string.
https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest