diff --git a/lib/database.js b/lib/database.js index 9f7b4d8..82a817f 100644 --- a/lib/database.js +++ b/lib/database.js @@ -1,15 +1,15 @@ -var sqlite = require('sqlite3'); +exports.setup = function() { + var sqlite = require('sqlite3'); -var db = new sqlite.Database('database.sql'); + var db = new sqlite.Database('database.sql'); -exports.log = function(ip, timestamp, playerCount) { - var insertStatement = db.prepare('INSERT INTO pings (timestamp, ip, player) VALUES (?, ?, ?)'); - - insertStatement.run(timestamp, ip, playerCount); -}; - -exports.setup = function(fileName) { db.serialize(function() { db.run('CREATE TABLE IF NOT EXISTS pings (id INT AUTO INCREMENT PRIMARY KEY, timestamp BIGINT NOT NULL, ip TINYTEXT, player MEDIUMINT)'); }); + + exports.log = function(ip, timestamp, playerCount) { + var insertStatement = db.prepare('INSERT INTO pings (timestamp, ip, player) VALUES (?, ?, ?)'); + + insertStatement.run(timestamp, ip, playerCount); + }; }; \ No newline at end of file