var DB = require("topsin.database");
var _e = require("topsin.error");

var DEMO_CONN = 'DEMO_CONN';
DB.addConnection({
  database_type: "mssql",
  database_host: "10.3.1.250\\MSSQLSERVER",
  database_name: "Unitech3",
  database_user: "TopLinker",
  database_pwd: "837914",
  database_driver: "/usr/local/freetds/lib/libtdsodbc.so.0" // OR FreeTDS
}, DEMO_CONN);

var query = DB.query(DEMO_CONN);
query.begin();
try {
  var r = query.selectValue('SELECT 1', {});
  if (query.lastError().isValid()) {
    throw query.lastError().text();
  }
  print("r: ", r);
  query.commit();
} catch (e) {
  query.rollback();
  print(e);
}

DB.removeConnection(DEMO_CONN);