dump sql files

This commit is contained in:
Paul Trowbridge 2018-08-16 11:59:13 -04:00
parent aa797b7fa8
commit 938e5321dc
2 changed files with 16 additions and 10 deletions

1
osm.sql Normal file
View File

@ -0,0 +1 @@
SELECT * FROM RLARP.OSM WHERE ITER > '2018-08-15-11.23.42.009654'

View File

@ -28,16 +28,16 @@ namespace test
//ibmcmd.CommandText = "SELECT * FROM LGDAT.GLDATE";
//ibmcmd.CommandText = "SELECT * FROM LGDAT.STKMM";
ibmcmd.CommandText = System.IO.File.ReadAllText(@"C:\Users\ptrowbridge\Documents\runner\stkmm.sql");
ibmcmd.CommandText = System.IO.File.ReadAllText(@"C:\Users\ptrowbridge\Documents\runner\osm.sql");
var pgcmd = new NpgsqlCommand();
pgcmd.Connection = pgc;
//pgcmd.CommandText = "SELECT * FROM rlarp.trig_log_eav WHERE 0=1";
//pgcmd.CommandText = "SELECT * FROM rlarp.osmi WHERE 0=1";
pgcmd.CommandText = "SELECT * FROM rlarp.osmi WHERE 0=1";
//pgcmd.CommandText = "SELECT * FROM lgdat.gldate WHERE 0=1";
pgcmd.CommandText = "SELECT * FROM lgdat.stkmm WHERE 0=1";
//pgcmd.CommandText = "SELECT * FROM lgdat.stkmm WHERE 0=1";
//---------------------------------------------setup adapters---------------------------------------------------------
//var ibmds = new System.Data.DataSet();
@ -52,19 +52,21 @@ namespace test
Console.Write("etl start:" + DateTime.Now.ToString());
Console.Write(Environment.NewLine);
pgc.BeginTransaction();
//--------------------------------------------move to target--------------------------------------------------------
var ibmdr = ibmcmd.ExecuteReader();
var getv = new object[ibmdr.FieldCount];
int r = 0;
int t = 0;
string sql = "";
string nr = "";
string nc = "";
var pgcom = pgc.CreateCommand();
while (ibmdr.Read()) {
r = r + 1;
t = t +1 ;
nr = "";
/*
for ( int i = 0 ; i < ibmdr.GetValues(getv);i++) {
if (getv[i] != null) {
switch (ibmdr.GetDataTypeName(i)){
@ -105,17 +107,20 @@ namespace test
sql = sql + ",";
}
sql = sql + "(" + nr + ")";
if (r == 500) {
if (r == 250) {
r = 0;
pgcom.CommandText = "INSERT INTO lgdat.stkmm VALUES " + sql;
//pgcom.ExecuteNonQuery();
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
pgcom.CommandText = sql;
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
pgcom.ExecuteNonQuery();
sql = "";
}
*/
}
if (r != 0) {
pgcom.CommandText = "INSERT INTO lgdat.stkmm VALUES " + sql;
//pgcom.ExecuteNonQuery();
sql = "INSERT INTO rlarp.osmi VALUES " + sql;
pgcom.CommandText = sql;
System.IO.File.WriteAllText(@"C:\Users\ptrowbridge\Downloads\"+ t.ToString()+".sql",sql);
pgcom.ExecuteNonQuery();
sql = "";
}