node.js - using mysql in Electron -
im trying use mysql
in electron i'm running error
typeerror: invalid data, chunk must string or buffer, not object @ socket.write (net.js:667) @ protocol.<anonymous> (connection.js:100)
with code
var mysql = require('mysql'); var con = mysql.createconnection({ host: 'host address', user: 'username', password: 'pw', database: 'db name', }); con.connect(err => { if(err) throw err }) con.query('select * books', (err2, result) => { if(err2) { throw err2; } console.log(result); })
if paste test.js
file , run node
runs 100% fine without errors, im not sure im going wrong here
so turns issue had fact running angular on electron. if put code inside angular code error out if put in index.html
run fine.
made little proxy function in index.html
connecting db , making queries, i'd jsut call inside angular app without problem window.mysqlquery(querystring)
wiki
Comments
Post a Comment