Exemple #1
0
        static void insertlast(Dictionary <string, SortedList <string, List <string> > > listnew)
        {
            SqliteAccess sqlite = new SqliteAccess("E:\\临时测试程序\\GetDBData\\DataBase3.db3");
            //SqliteAccess sqlite = new SqliteAccess("C:\\Users\\ysjsfw\\Desktop\\DataBase3.db3");
            string        strlist   = "";
            StringBuilder stblist   = new StringBuilder();
            string        str       = "";
            int           count     = 0;
            int           countall  = 0;
            string        strinsert = @"INSERT INTO CHDQUOTE
                            (TDATE,
                              EXCHANGE,
                              SYMBOL,
                              SNAME,
                              LCLOSE,
                              TOPEN,
                              TCLOSE,
                              HIGH,
                              LOW,
                              VOTURNOVER,
                              VATURNOVER,
                              NDEALS,
                              AVGPRICE,
                              AVGVOLPD,
                              AVGVAPD,
                              CHG,
                              PCHG,
                              PRANGE,
                              MCAP,
                              TCAP,
                              TURNOVER
                            )
                            VALUES({0})";
            string        temp      = "";

            foreach (var sort in listnew)
            {
                foreach (var item in sort.Value)
                {
                    count++;
                    if (count > 1236000)
                    {
                        foreach (var i in item.Value)
                        {
                            temp += "'" + Convert.ToString(i) + "',";
                        }
                        temp = temp.Substring(0, temp.Length - 1);
                        stblist.Append(string.Format(strinsert, temp) + ";");
                        temp = "";
                        sqlite.ExecuteTran(stblist.ToString(), out str);
                        stblist = new StringBuilder();
                        Console.WriteLine(count.ToString());
                    }
                }
            }
        }
Exemple #2
0
        public static void insertDB(Dictionary <string, SortedList <string, List <string> > > listnew, string DBLINK)
        {
            SqliteAccess sqlite = new SqliteAccess("xiaxie");
            //SqliteAccess sqlite = new SqliteAccess("C:\\Users\\ysjsfw\\Desktop\\DataBase3.db3");
            //string DBLINK = @"Data Source=E:\\临时测试程序\\GetDBData\\DataBase.db3;Pooling=true;FailIfMissing=false";
            //string DBLINK = @"Data Source=C:\\Users\\ysjsfw\\Desktop\\DataBase.db3;Pooling=true;FailIfMissing=false";
            StringBuilder stblist     = new StringBuilder();
            int           count       = 0; //当前批次数量
            int           countFinish = 0; //已完成数量
            List <string> list        = new List <string>();
            string        strinsert   = @"INSERT INTO EQ_DReturn
                            (Tdate,Symbol,Exchange,DType,R,LTDR,SECode
                            )
                            VALUES({0})";
            string        temp        = "";

            //代码索引
            foreach (var sort in listnew)
            {
                //日期索引
                foreach (var item in sort.Value)
                {
                    //拼接字段
                    foreach (var i in item.Value)
                    {
                        temp += "'" + Convert.ToString(i) + "',";
                    }
                    temp = temp.Substring(0, temp.Length - 1);
                    list.Add(string.Format(strinsert, temp));
                    temp = "";
                    count++;
                    //5000个一批次插入
                    if (count == 5000)
                    {
                        sqlite.insertQuick(DBLINK, list);
                        list         = new List <string>();
                        count        = 0;
                        countFinish += 5000;
                        Console.WriteLine(countFinish.ToString());
                    }
                }
            }
            Console.WriteLine("countFinish:" + countFinish.ToString());
            Console.WriteLine("count:" + count.ToString());

            //不足5000批次插入
            if (list.Count > 0)
            {
                sqlite.insertQuick(DBLINK, list);
            }
        }
Exemple #3
0
        /// <summary>
        /// 直接插入数据库
        /// </summary>
        /// <param name="listnew"></param>
        public static void insert(List <List <string> > listnew)
        {
            SqliteAccess sqlite = new SqliteAccess("E:\\临时测试程序\\GetDBData\\DataBase3.db3");
            //SqliteAccess sqlite = new SqliteAccess("C:\\Users\\ysjsfw\\Desktop\\DataBase3.db3");
            string DBLINK = @"Data Source=E:\\临时测试程序\\GetDBData\\DataBase.db3;Pooling=true;FailIfMissing=false";
            //string DBLINK = @"Data Source=C:\\Users\\ysjsfw\\Desktop\\DataBase.db3;Pooling=true;FailIfMissing=false";
            StringBuilder stblist     = new StringBuilder();
            int           count       = 0;
            int           countFinish = 0;
            List <string> list        = new List <string>();
            string        strinsert   = @"INSERT INTO eq_dispara
                            (Tdate,Exchange,Symbol,DType,D_nt,F_nt,S_nt,K_nt,C_nt,TClose,LClose,R,SECode)
                            VALUES({0})";
            string        temp        = "";

            foreach (var sort in listnew)
            {
                foreach (var i in sort)
                {
                    temp += "'" + Convert.ToString(i) + "',";
                }
                temp = temp.Substring(0, temp.Length - 1);
                list.Add(string.Format(strinsert, temp));
                temp = "";
                count++;

                if (count == 5000)
                {
                    sqlite.insertQuick(DBLINK, list);
                    list         = new List <string>();
                    count        = 0;
                    countFinish += 5000;
                    Console.WriteLine(countFinish.ToString());
                }
            }
            Console.WriteLine("countFinish:" + countFinish.ToString());
            Console.WriteLine("count:" + count.ToString());
            if (list.Count > 0)
            {
                sqlite.insertQuick(DBLINK, list);
            }
        }
Exemple #4
0
        static void newinsert(Dictionary <string, SortedList <string, List <string> > > listnew)
        {
            SqliteAccess sqlite = new SqliteAccess("E:\\临时测试程序\\GetDBData\\DataBase3.db3");
            //SqliteAccess sqlite = new SqliteAccess("C:\\Users\\ysjsfw\\Desktop\\DataBase3.db3");
            //string DBLINK = @"Data Source=E:\\临时测试程序\\GetDBData\\DataBase3.db3;Pooling=true;FailIfMissing=false";
            string        DBLINK    = @"Data Source=C:\\Users\\ysjsfw\\Desktop\\DataBase.db3;Pooling=true;FailIfMissing=false";
            StringBuilder stblist   = new StringBuilder();
            int           count     = 0;
            int           countall  = 0;
            List <string> list      = new List <string>();
            string        strinsert = @"INSERT INTO CHDQUOTE
                            (TDATE,
                              EXCHANGE,
                              SYMBOL,
                              SNAME,
                              LCLOSE,
                              TOPEN,
                              TCLOSE,
                              HIGH,
                              LOW,
                              VOTURNOVER,
                              VATURNOVER,
                              NDEALS,
                              AVGPRICE,
                              AVGVOLPD,
                              AVGVAPD,
                              CHG,
                              PCHG,
                              PRANGE,
                              MCAP,
                              TCAP,
                              TURNOVER
                            )
                            VALUES({0})";
            string        temp      = "";

            foreach (var sort in listnew)
            {
                foreach (var item in sort.Value)
                {
                    foreach (var i in item.Value)
                    {
                        temp += "'" + Convert.ToString(i) + "',";
                    }
                    temp = temp.Substring(0, temp.Length - 1);
                    list.Add(string.Format(strinsert, temp));
                    temp = "";
                    count++;

                    if (count == 5000)
                    {
                        sqlite.insertQuick(DBLINK, list);
                        list      = new List <string>();
                        count     = 0;
                        countall += 5000;
                        Console.WriteLine(countall.ToString());
                    }
                }
            }
            Console.WriteLine("countall:" + countall.ToString());
            Console.WriteLine("count:" + count.ToString());
            if (list.Count > 0)
            {
                sqlite.insertQuick(DBLINK, list);
            }
        }