Esempio n. 1
0
        public void Insert1000RowsAndCount_Commit()
        {
            // we deisable the AUTO_COMMIT flag for such this operation
            DeveelDbTransaction transaction = Connection.BeginTransaction();

            DeveelDbCommand command = Connection.CreateCommand();;

            DateTime start = DateTime.Now;

            for (int i = 0; i < 1000; i++)
            {
                command.CommandText = "INSERT INTO TestTable (inc, var_name) VALUES (?, ?)";
                command.Parameters.Add(i);
                command.Parameters.Add("var_" + i);
                command.ExecuteNonQuery();
            }

            DateTime end = DateTime.Now;

            Console.Out.WriteLine("Inserted 1000 rows in {0}.", (end - start));

            start = DateTime.Now;

            transaction.Commit();

            end = DateTime.Now;

            Console.Out.WriteLine("Committed in {0}.", (end - start));

            command = Connection.CreateCommand("SELECT COUNT(*) FROM TestTable");
            BigNumber count = (BigNumber)command.ExecuteScalar();

            Console.Out.WriteLine("Numer of rows inserted into TestTable : {0}", count);
        }
Esempio n. 2
0
        protected override void OnSetUp()
        {
            DeveelDbCommand command = Connection.CreateCommand();

            command.CommandText = "CREATE TABLE IF NOT EXISTS TestTable (" +
                                  "    id IDENTITY," +
                                  "    inc INTEGER," +
                                  "    var_name VARCHAR(200)" +
                                  ")";
            command.ExecuteNonQuery();
        }
Esempio n. 3
0
        protected override void OnTearDown()
        {
            DeveelDbCommand command = Connection.CreateCommand("DROP TABLE TestTable");

            command.ExecuteNonQuery();
        }