Last active
April 21, 2017 05:08
-
-
Save theredstapler/623a27fe86b0e118736c7e891ba76ff6 to your computer and use it in GitHub Desktop.
Code for electron tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script>window.$ = window.jQuery = require('./jquery-2.1.4.js');</script> | |
</head> | |
<body> | |
<h1>Electron MySQL Example</h1> | |
<div id="resultDiv"></div> | |
<script> | |
var mysql = require('mysql'); | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
user : 'root', | |
password : null, | |
database : 'electron_db' | |
}); | |
connection.connect(); | |
$sql = 'SELECT `emp_id`,`emp_name` FROM `employee`'; | |
connection.query($sql, function (error, results, fields) { | |
if (error) throw error; | |
console.log(results); | |
$('#resultDiv').text(results[0].emp_name); | |
}); | |
connection.end(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Visit Full article at our official site: Electron Mysql tutorial