You are on page 1of 1

class Program

static void Main(string[] args)


{
SQLiteConnection con;
SQLiteCommand cmd;

con = new SQLiteConnection("Data Source=OrnekVt.sqlite;Version=3;");


string sql = @"CREATE TABLE IF NOT EXISTS Ogrenci(
OgrNo INTEGER PRIMARY KEY AUTOINCREMENT ,
Ad TEXT NOT NULL,
Soyad TEXT NOT NULL
);";

con.Open();
cmd = new SQLiteCommand(sql, con);
cmd.ExecuteNonQuery();

/* 1 Milyon kayıt ekleme*/

var stopwatch = new Stopwatch();


stopwatch.Start();
cmd = new SQLiteCommand();

using (cmd = new SQLiteCommand(con))


{
using (var transaction = con.BeginTransaction())
{
for (var i = 0; i < 1000000; i++)
{
cmd.CommandText = "insert into Ogrenci(Ad,Soyad) values
('Ali','Bak')";
cmd.ExecuteNonQuery();
}

transaction.Commit();
}
}

Console.WriteLine("****** 1 Milyon Kayıt Eklendi *****");


Console.WriteLine("{0} saniye sürdü", stopwatch.Elapsed.TotalSeconds);

con.Close();

Console.ReadLine();

}
}

You might also like