X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=dbgenerate.js;h=0ea16fda806638b796beb905bec622c88ae15d72;hb=119290bc3234e9ece1c64dbd72ca486d9633b5b7;hp=f75d90a718314c0cdbc48361fd6f66960484db3b;hpb=ef57d66d064da8f0546eeabf5cf8ee900d1f1b99;p=app.Builder.js diff --git a/dbgenerate.js b/dbgenerate.js index f75d90a71..0ea16fda8 100644 --- a/dbgenerate.js +++ b/dbgenerate.js @@ -55,7 +55,7 @@ var o = new Options({ { arg_long : 'DBTYPE' , arg_short : 't', description : 'Database Type (eg. MySQL or PostgreSQL ' }, { arg_long : 'DBNAME' , arg_short : 'd', description : 'Database Name' }, { arg_long : 'USERNAME' , arg_short : 'u', description : 'Username'}, - { arg_long : 'PASSWORD' , arg_short : 'p', description : '' , arg_default :'' }, + { arg_long : 'PASSWORD' , arg_short : 'p', description : 'Password' , arg_default :'' }, { arg_long : 'INI' , arg_short : 'I', description : 'Either base directory which has Pman/***/DataObjects/***.links.ini or location of ini file.' }, ] @@ -159,16 +159,22 @@ function readIni(fn) var groups = key_file.get_groups(); groups.forEach(function(g) { + //print("KEY:"+g); ini[g] = {} - print("KEY:"+g); + var keys = key_file.get_keys(g); if (!keys) { return; } - keys.forEach(function(k) { - ini[g][k] = key_file.get_value(g,k); - }) - }) - + + keys.forEach(function(k) { + print("GET val: " + k); + ini[g][k] = key_file.get_value(g,k); + print(ini[g][k] ); + }); + //print("DONE KEY:"+g); + }); + //print("DONE KEYS"); } + if (File.isFile(cfg.INI)) { if (cfg.INI.match(/links\.ini$/)) { readIni(cfg.INI); @@ -228,7 +234,7 @@ if (File.isDirectory(cfg.INI)) { } //print(JSON.stringify(ini, null,4)); //console.dump(ini); - +print("DONE INI"); //Seed.quit(); @@ -273,7 +279,11 @@ switch(cfg.DBTYPE) { break; default: - throw "Invalid data base type " + cfg.DBTYPE + " should be MySQL or PostgreSQL"; + throw { + name: "ArgumentError", + message: "Invalid data base type " + cfg.DBTYPE + " should be MySQL or PostgreSQL" + }; + /* "Field": "province", "Type": "varchar(255)", @@ -287,13 +297,13 @@ switch(cfg.DBTYPE) { -var tables = Gda.execute_select_command(cnc, query_tables).fetchAll(); +var tables = cnc.execute_select_command( query_tables).fetchAll(); print(JSON.stringify(tables)); var readers = []; tables.forEach(function(table) { //print(table); - var schema = Gda.execute_select_command(cnc, + var schema = cnc.execute_select_command( query_describe_table.replace(/%s/, table).replace(/%n/,'public') ).fetchAll(); @@ -309,8 +319,8 @@ tables.forEach(function(table) { //print(JSON.stringify(schema, null,4)); Seed.quit(); schema.forEach(function(e) { - e.Type = e.type; - e.Field = e.field; + e.Type = e.Type || e.type; + e.Field = e.Field || e.field; var type = e.Type.match(/([^(]+)\(([^\)]+)\)/); var row = { };