diff --git a/SQLite_Console/SQLite_Console.sln b/SQLite_Console/SQLite_Console.sln new file mode 100644 index 0000000..b282dae --- /dev/null +++ b/SQLite_Console/SQLite_Console.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32630.194 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite_Console", "SQLite_Console\SQLite_Console.csproj", "{A4457E3F-0254-45B1-B1AF-6196AA25B9B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A4457E3F-0254-45B1-B1AF-6196AA25B9B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4457E3F-0254-45B1-B1AF-6196AA25B9B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4457E3F-0254-45B1-B1AF-6196AA25B9B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4457E3F-0254-45B1-B1AF-6196AA25B9B9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6039406C-CEDB-43AB-9BE8-01020554E0A9} + EndGlobalSection +EndGlobal diff --git a/SQLite_Console/SQLite_Console/App.config b/SQLite_Console/SQLite_Console/App.config new file mode 100644 index 0000000..d27de0f --- /dev/null +++ b/SQLite_Console/SQLite_Console/App.config @@ -0,0 +1,22 @@ + + + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SQLite_Console/SQLite_Console/Program.cs b/SQLite_Console/SQLite_Console/Program.cs new file mode 100644 index 0000000..c73d86d --- /dev/null +++ b/SQLite_Console/SQLite_Console/Program.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SQLite; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SQLite_Console +{ + class Program + { + static void Main(string[] args) + { + string connString = @"Data Source = D:\SQLite\mydb.db"; + using (SQLiteConnection conn = new SQLiteConnection(connString)) + { + Stopwatch watch = new Stopwatch(); + watch.Start(); + + conn.Open(); + + watch.Stop(); + Console.WriteLine($"open: {watch.ElapsedMilliseconds}ms"); + Console.WriteLine(); + watch.Restart(); + + Random rnd = new Random(); + for (int i = 0; i < 2000; i++) + { + string guid = Guid.NewGuid().ToString(); + int age = rnd.Next(1, 100); + string name = $"Robot#{i + 1}"; + string insertQry = $"INSERT INTO member VALUES ('{name}', {age}, '{guid}')"; + SQLiteCommand cmd = new SQLiteCommand(insertQry, conn); + cmd.ExecuteNonQuery(); + } + + watch.Stop(); + Console.WriteLine($"insert: {watch.ElapsedMilliseconds}ms"); + Console.WriteLine(); + watch.Restart(); + + DataSet ds = new DataSet(); + string selectQry = "SELECT * FROM member"; + SQLiteDataAdapter adt = new SQLiteDataAdapter(selectQry, conn); + adt.Fill(ds); + + DataRowCollection rows = ds.Tables[0].Rows; + PrintRows(rows); + + watch.Stop(); + Console.WriteLine($"select all: {watch.ElapsedMilliseconds}ms"); + Console.WriteLine(); + watch.Restart(); + + selectQry = "SELECT * FROM member WHERE age < 50"; + adt = new SQLiteDataAdapter(selectQry, conn); + adt.Fill(ds); + + rows = ds.Tables[0].Rows; + PrintRows(rows); + + watch.Stop(); + Console.WriteLine($"select under 50: {watch.ElapsedMilliseconds}ms"); + Console.WriteLine(); + watch.Restart(); + } + + Console.ReadKey(); + } + + private static void PrintRows(DataRowCollection rows) + { + Console.WriteLine($"found {rows.Count} rows."); + foreach (DataRow row in rows) + { + string name = (string)row["name"]; + long age = DBNull.Value.Equals(row["age"]) ? -1 : (long)row["age"]; + string guid = (string)row["guid"]; + + Console.WriteLine($"name: {name}, age: {age}, guid: {guid}"); + } + } + } +} diff --git a/SQLite_Console/SQLite_Console/Properties/AssemblyInfo.cs b/SQLite_Console/SQLite_Console/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e32a19a --- /dev/null +++ b/SQLite_Console/SQLite_Console/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SQLite_Console")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SQLite_Console")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("a4457e3f-0254-45b1-b1af-6196aa25b9b9")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SQLite_Console/SQLite_Console/SQLite_Console.csproj b/SQLite_Console/SQLite_Console/SQLite_Console.csproj new file mode 100644 index 0000000..86ce942 --- /dev/null +++ b/SQLite_Console/SQLite_Console/SQLite_Console.csproj @@ -0,0 +1,82 @@ + + + + + + Debug + AnyCPU + {A4457E3F-0254-45B1-B1AF-6196AA25B9B9} + Exe + SQLite_Console + SQLite_Console + v4.5 + 512 + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + + + + ..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\lib\net45\System.Data.SQLite.dll + + + ..\packages\System.Data.SQLite.EF6.1.0.117.0\lib\net45\System.Data.SQLite.EF6.dll + + + ..\packages\System.Data.SQLite.Linq.1.0.117.0\lib\net45\System.Data.SQLite.Linq.dll + + + + + + + + + + + + + + + + + + + + 이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다. + + + + + + + + \ No newline at end of file diff --git a/SQLite_Console/SQLite_Console/packages.config b/SQLite_Console/SQLite_Console/packages.config new file mode 100644 index 0000000..ad6d85a --- /dev/null +++ b/SQLite_Console/SQLite_Console/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file