mdot_mqtt/dbconfig.js
Martin Donnelly 410ebd5beb sql
2016-08-12 10:19:58 +01:00

39 lines
613 B
JavaScript

/**
*
* User: Martin Donnelly
* Date: 2016-04-04
* Time: 14:46
*
*/
var exec = require('child_process').exec;
function prepare_db() {
exec('psql -Upostgres -h localhost -f ./mdot.sql', function(err) {
if (err !== null) {
console.log('exec error: ' + err);
return -1;
} else {
console.log('Done?');
}
});
}
function createDB() {
'use strict';
exec('createdb -Upostgres -h localhost mdot', function(err) {
if (err !== null) {
console.log('exec error: ' + err);
return -1;
} else {
prepare_db();
}
});
}
prepare_db();