use("ODBC");

var people = {};
people["authur"] = 30;
people["ford"] = 42;
people["trillian"] = 29;
people["zaphod"] = 304;
people["marvin"] = 1000001;


db = new ODBC("freeswitch", "mylogin", "mypass");
db.connect();

db.exec("create table demo (name varchar(255), age varchar(80));");

for (var i in people) {
    sql = "insert into demo values('" + i + "', " + people[i] + ");";
    console_log("debug", sql + "\n");
    db.exec(sql);
}

sql = "select * from demo;";
var line = "==============================\n";

console_log("notice", line);

db.exec(sql);

console_log("debug", "row count: " + db.numRows() + "\n");

while(db.nextRow()) {
    var row = db.getData();

    for (var i in row) {
        console_log("debug", "[" + i + "] = [" + row[i] + "]\n");
    }

    console_log("debug", "\n");
}



console_log("notice", line);

db.exec("drop table demo");