Access a MySQL Database in Electron

2019-03-28 03:53发布

问题:

I am using Electron to create an app, and wanted to get to select and insert/update some table in a MySQL Database in my localhost, how can I make the connection with the Database ?

PS: I am very new to Electron

Thank you for your help.

回答1:

Electron is the combination of Chromium, the web renderer used in Chrome, and Node.js. Adding Node.js to the mix gives Electron the ability to work with the native OS in ways normal web pages cannot. With Node.js at your disposal you have access to all the libraries that are currently available to Node, and so the answer to this question is the same as the answer to how to connect to MySQL from Node.js which you can find here: MySQL with Node.js. The code in this answer should work in Electron.