+ 1
What is the best way to import a sql file into a js file by node and how to use sql file query in the js file
2 Antworten
+ 1
I'm assuming this question has been covered in previous questions, i recommend you use the search feature and look at some of those.
If you want to open a .sql file use "fs" library to open it and use "sqlite3" library to query it, you can see an example here https://gist.github.com/TheoOkafor/1762e455b0e76c6764f0deabc08c8a77#file-index-js
More commonly youll be working with live databases in which case it depends on the exact database you want to query, ex. MySQL you would the "mysql" library. https://www.w3schools.com/nodejs/nodejs_mysql.asp
+ 1
Go to https://glitch.com sign up an account, you can setup and use a node.js code with sqlite right from the startup template.