How to use the mysql.query function in mysql

To help you get started, we’ve selected a few mysql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskrabbit / empujar / test / connections / mysql.js View on Github external
it('can query (read)', function(done){
      mysql.query('select * from users order by id asc', function(error, rows){
        should.not.exist(error);
        rows.length.should.equal(3);
        rows[0].email.should.equal('evan@taskrabbit.com');
        done();
      });
    });
github taskrabbit / empujar / test / connections / mysql.js View on Github external
it('can query (write) (data)', function(done){
        mysql.query('INSERT INTO `users` (`id`, `email`, `first_name`, `counter`) VALUES (?, ?, ?, ?)', [5, 'saba@taskrabbit.com', 'saba', 30], function(error, response){
          should.not.exist(error);
          response.rows.should.equal(1);
          done();
        });
      });
github taskrabbit / empujar / test / connections / mysql.js View on Github external
it('can query (write) (raw)', function(done){
        mysql.query('INSERT INTO `users` (`id`, `email`, `first_name`, `counter`) VALUES (4, \'paul@taskrabbit.com\', \'paul\', 10)', function(error, response){
          should.not.exist(error);
          response.rows.should.equal(1);
          done();
        });
      });
github kangkk / kc-cms / models / api / object.js View on Github external
queryMysql: function (sql ,callback){
			//console.log(sql);
			mysql.query(sql,function(err,rows,fields){
		 		if(err){
					throw err;
				}else{
					callback(err,rows,fields);
		        		}
		        		//console.log('\n');for (var i in rows) {console.log(rows[i]);}
		        		//console.log('\n');for (var i in fields) {console.log(fields[i]);}
		    	});//mysql.end();
		},
		checkLogin: function (req, res, next) {
github lampaa / NodeSmarty / others / express.example.js View on Github external
app.get('/', function(req, res){
	mySql.query('SELECT * FROM test', function(error, result, fields){

		if (error){
			throw error;
		}
		
		Template.assign({
			'values':fields
		}); 
		
		var Final = Template.fetchSync('data.html');
		
		res.send(Final);

		client.end();
	});	
});