var DB = require("topsin.database");
var _ = require("lodash");
var TError = require("topsin.error");
var logger = require('topsin.logger')
var moment = require('moment')

DB.addConnection({
    database_type: 'mssql',
    database_host: '139.196.104.13',
    database_name: 's_cell',
    database_user: 'sa',
    database_pwd: 'TopLinker0510'
}, 'DEMO_CONN');

try {
    DB.query('DEMO_CONN', function (query) {
        var ok = query.selectValue("SELECT 1", {});
        if (query.lastError().isValid()) {
            throw query.lastError().text();
        }
        print("ok: ", ok);
        var last_inserted_id = query.insertRow({
            table: 'sys_user',
            data: {
                "username": "test_20200530"
            },
            return_field: 'id'
        });
        if (query.lastError().isValid()) {
            throw query.lastError().text();
        }
        print("last_inserted_id: ", last_inserted_id);
    })
} catch (e) {
    print(e);
}
