<commit_before>var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var pg = require('pg');
var favicon = require('serve-favicon');

var port = process.env.PORT || process.env.NODE_PORT || 3000;

var conString = "pg://other_user:u_pick_it@192.168.3.11:5432/ellucian";
var client = new pg.Client(conString);

http.listen(port, function(err) {
	 console.log('listening on ' + port);
});

app.get('/', function (req, res) {
  res.sendFile(__dirname + '/client/index.html');
});

app.use(favicon(__dirname + '/client/favicon.ico'));

io.on('connection', function(socket){
	console.log('a user connected');
	
	socket.on('create', function(req) {
		pg.connect(conString, function(err, client, done) {
			console.log(req.create1);
			console.log(req.create2);
			var query = client.query(req.create1);
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
		});
		pg.connect(conString, function(err, client, done) {
			var query = client.query(req.create2);
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
		});
	});
	  
	socket.on('insert', function(req) {
		//console.log(req);
		var results = [];
		pg.connect(conString, function(error, client, done) {
			var query = client.query(req.insert1).on("row", function (row) {
				console.log(row);
				results.push(row);
				done();
			});
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
			console.log(req.insert1);
		});
		pg.connect(conString, function(error, client, done) {
			var query = client.query(req.insert2).on("row", function (row) {
				results.push(row);
				done();
			});
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
			console.log(req.insert2);
		});
	});
	  
	socket.on('select', function(req) {
		var results = [];
		pg.connect(conString, function(err, client, done) {			
			var query = client.query(req, function (err, result) {
				// Write out as HTML output
				socket.emit('table', result);
				done();
			});
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
		});
	});
	  
	socket.on('put', function(req) {
		pg.connect(conString, function(err, client, done) {
			var query = client.query(req);<commit_msg>Favicon out<commit_after>var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var pg = require('pg');

var port = process.env.PORT || process.env.NODE_PORT || 3000;

var conString = "pg://other_user:u_pick_it@192.168.3.11:5432/ellucian";
var client = new pg.Client(conString);

http.listen(port, function(err) {
	 console.log('listening on ' + port);
});

app.get('/', function (req, res) {
  res.sendFile(__dirname + '/client/index.html');
});

io.on('connection', function(socket){
	console.log('a user connected');
	
	socket.on('create', function(req) {
		pg.connect(conString, function(err, client, done) {
			console.log(req.create1);
			console.log(req.create2);
			var query = client.query(req.create1);
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
		});
		pg.connect(conString, function(err, client, done) {
			var query = client.query(req.create2);
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
		});
	});
	  
	socket.on('insert', function(req) {
		//console.log(req);
		var results = [];
		pg.connect(conString, function(error, client, done) {
			var query = client.query(req.insert1).on("row", function (row) {
				console.log(row);
				results.push(row);
				done();
			});
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
			console.log(req.insert1);
		});
		pg.connect(conString, function(error, client, done) {
			var query = client.query(req.insert2).on("row", function (row) {
				results.push(row);
				done();
			});
			query.on('error', function(error) {
				//handle the error
				console.log(error);
				done(client);
				client = new pg.Client(conString);
				error = "Incorrect syntax";
				socket.emit('err', error);
			});
			console.log(req.insert2);
		});
	});
	  
	socket.on('select', function(req) {
		var results = [];
		pg.connect(conString, function(err, client, done) {			
			var query = client.query(req, function (err, result) {
				// Write out as HTML output
				if(err) {
					console.log(err);
					done(client);
					client = new pg.Client(conString);
					error = "Incorrect syntax";
					socket.emit('err', err);
				} else {
					socket.emit('table', result);
					done();
				}
			});
		});
	});
	  
	socket.on('put', function(req) {
		pg.connect(conString, function(err, client, done) {
			var query = client.query(req);
{'fraction_non_alphanumeric': 0.18402356610639403, 'fraction_numerical': 0.008664009703690868, 'mean_word_length': 3.4468412942989213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '426615', 'n_tokens_mistral': 2334, 'n_tokens_neox': 1935, 'n_words': 390}