public void create_table(dbtable t) { StringBuilder cmd = new StringBuilder("create table " + t.name + "("); for (int i = 0; i < t.fields.Length; i++) { if (i != 0) { cmd.Append(','); } cmd.Append(t.fields [i].name + " "); string type_name; if (t.fields [i].type == dbfield.types.str) { if (t.fields [i].len <= 0) { type_name = "text"; } else { type_name = "varchar(" + t.fields [i].len.ToString() + ")"; } } else { type_name = type_names [(int)t.fields [i].type]; } cmd.Append(type_name); } Npgsql.NpgsqlCommand c = new Npgsql.NpgsqlCommand(cmd.ToString(), con); c.ExecuteNonQuery(); table_mapping [t.id] = new table_entry(t); }
public void create_table(dbtable t) { StringBuilder cmd = new StringBuilder("create table " + t.name + "("); for (int i = 0; i < t.fields.Length; i++) { if (i != 0) { cmd.Append(','); } cmd.Append(t.fields [i].name + " "); string type_name; if (t.fields [i].type == dbfield.types.str) { if (t.fields [i].len <= 0) { type_name = "ntext"; } else { type_name = "nvarchar(" + t.fields [i].len.ToString() + ")"; } } else { type_name = type_names [(int)t.fields [i].type]; } cmd.Append(type_name); } System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand(cmd.ToString(), con); c.Transaction = trans; c.ExecuteNonQuery(); set_table(t); }
public static void Main(string[] args) { string[] tables = new string[] { "page_visit_log", "buysell", "business" }; s = new dbserializer(new System.IO.FileStream("tmp.out", System.IO.FileMode.Create)); db db1 = new mssql_db(); db1.set_params("cs", "data source=192.167.0.101;initial catalog=vanbusiness;persist security info=False;user id=user1;password=passw0rd!;packet size=32768"); db1.connect(); s.write_header(); for (int i = 0; i < tables.Length; i++) { dbtable t = new dbtable(); t.id = i; t.name = tables [i]; s.put_table(t); db1.get_rows(t, process_row); } }
public void get_rows(dbtable t, row_cb cb) { string cmd = "select * from " + t.name; System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand(cmd, con); c.Transaction = trans; System.Data.SqlClient.SqlDataReader r = c.ExecuteReader(); while (r.Read()) { object[] o = new object[r.FieldCount]; r.GetValues(o); dbrow row; row.fields = o; row.table_id = t.id; cb(row); } r.Close(); }
public table_entry (dbtable t) { this.t = t; }
public static void Main (string[] args) { string[] tables = new string[]{"page_visit_log","buysell","business"}; s = new dbserializer (new System.IO.FileStream ("tmp.out", System.IO.FileMode.Create)); db db1 = new mssql_db (); db1.set_params ("cs", "data source=192.167.0.101;initial catalog=vanbusiness;persist security info=False;user id=user1;password=passw0rd!;packet size=32768"); db1.connect (); s.write_header (); for (int i=0; i<tables.Length; i++) { dbtable t = new dbtable (); t.id = i; t.name = tables [i]; s.put_table (t); db1.get_rows(t,process_row); } }
public void put_table (dbtable t) { formatter.Serialize (s, t); }
public void create_table (dbtable t) { StringBuilder cmd = new StringBuilder ("create table " + t.name + "("); for (int i=0; i<t.fields.Length; i++) { if (i != 0) cmd.Append (','); cmd.Append (t.fields [i].name + " "); string type_name; if (t.fields [i].type == dbfield.types.str) { if (t.fields [i].len <= 0) { type_name = "text"; } else { type_name = "varchar(" + t.fields [i].len.ToString () + ")"; } } else type_name = type_names [(int)t.fields [i].type]; cmd.Append (type_name); } Npgsql.NpgsqlCommand c = new Npgsql.NpgsqlCommand (cmd.ToString (), con); c.ExecuteNonQuery (); table_mapping [t.id] = new table_entry (t); }
public void set_table (dbtable t) { table_mapping [t.id] = new table_entry (t); }
public void get_rows (dbtable t, row_cb cb) { }
public void create_table (dbtable t) { StringBuilder cmd = new StringBuilder ("create table " + t.name + "("); for (int i=0; i<t.fields.Length; i++) { if (i != 0) cmd.Append (','); cmd.Append (t.fields [i].name + " "); string type_name; if (t.fields [i].type == dbfield.types.str) { if (t.fields [i].len <= 0) { type_name = "ntext"; } else { type_name = "nvarchar(" + t.fields [i].len.ToString () + ")"; } } else type_name = type_names [(int)t.fields [i].type]; cmd.Append (type_name); } System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand (cmd.ToString (), con); c.Transaction=trans; c.ExecuteNonQuery (); set_table (t); }
public void get_rows (dbtable t, row_cb cb) { string cmd = "select * from " + t.name; System.Data.SqlClient.SqlCommand c = new System.Data.SqlClient.SqlCommand (cmd, con); c.Transaction=trans; System.Data.SqlClient.SqlDataReader r = c.ExecuteReader (); while (r.Read ()) { object[] o = new object[r.FieldCount]; r.GetValues (o); dbrow row; row.fields = o; row.table_id=t.id; cb (row); } r.Close (); }
public table_entry(dbtable t) { this.t = t; }
public void put_table(dbtable t) { formatter.Serialize(s, t); }
public void set_table(dbtable t) { table_mapping [t.id] = new table_entry(t); }
public void get_rows(dbtable t, row_cb cb) { }