Ejemplo n.º 1
0
        // 3. drop table & safe drop table
        public void drop_table(bool bSafe)
        {
            if (bSafe && !exists())
            {
                return;
            }

            var cmd_text = safeformat.format(@"use {0};drop table {1}", db_name, table_name);
            var cmd      = current_conn.prepare_write_cmd(cmd_text);

            current_conn.execute_nonquery(cmd);
        }
Ejemplo n.º 2
0
        // 2. fill data from src database
        public void fill_from(data.dbname src_database_name)
        {
            var           schema          = new cmd_wraper.table_cmd(conn, table_name, src_database_name).show_createtable();
            var           columns_match   = System.Text.RegularExpressions.Regex.Matches(schema, @"\n\s+\`[a-zA-Z_]+\`\s");
            List <string> usefull_columns = new List <string>();

            foreach (System.Text.RegularExpressions.Match m in columns_match)
            {
                var v    = m.Value.Split('`');
                var name = v[1];
                if (name == "id")
                {
                    continue;
                }
                usefull_columns.Add(name);
            }
            var init_sql_schema = @"insert into {0}.{1} (old_id,old_server,{2}) select id as old_id,'{3}'as old_server, {2} from {3}.{1};";
            var column_strs     = new StringBuilder();

            foreach (var v in usefull_columns)
            {
                column_strs.Append(v);
                column_strs.Append(",");
            }
            column_strs.Remove(column_strs.Length - 1, 1);

            var init_sql = safeformat.format(init_sql_schema, database_name.database_name, table_name.table_name, column_strs.ToString(), src_database_name.database_name);
            var cmd      = conn.prepare_write_cmd(init_sql);

            new cmd_wraper.connection_cmd(conn).run_sql_text(init_sql);
        }
Ejemplo n.º 3
0
        // 2. run_sql_text_cmd
        public void run_sql_text(string sql)
        {
            var cmd = current_db.prepare_write_cmd(sql);

            current_db.execute_nonquery(cmd);
        }