{"id":2290,"date":"2015-12-29T16:51:28","date_gmt":"2015-12-29T16:51:28","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=2290"},"modified":"2020-09-24T15:07:42","modified_gmt":"2020-09-24T06:07:42","slug":"c%ec%9c%bc%eb%a1%9c-sqlite-%eb%8b%a4%eb%a3%a8%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=2290","title":{"rendered":"C#\uc73c\ub85c SQLite \ub2e4\ub8e8\uae30"},"content":{"rendered":"<p>\uba54\ubaa8\ub9ac \uae30\ubc18\uc5d0\uc11c \uc790\ub8cc\ub97c \ub2e4\ub8e8\uae30 \uc704\ud574 Array\ub098 Linked List \uadf8\ub9ac\uace0 Hashmap \ub4f1\uc744 \uc0ac\uc6a9\ud558\uc9c0\ub9cc, \ub300\uc6a9\ub7c9 \ub610\ub294 SQL \ubb38\uc744 \ud1b5\ud55c \ub2e4\uc591\ud55c \uc870\uac74\uac80\uc0c9\uc744 \uc704\ud574 DBMS\uc744 \uc0ac\uc6a9\ud574\uc57c\ud560 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc124\uce58\ub3c4 \ud544\uc694\uc5c6\uace0 \uac00\ubccd\uace0 \ube60\ub974\uac8c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 Local DBMS\ub85c SQLite\ub294 \uc548\ub4dc\ub85c\uc774\ub4dc\ub098 SVN \ub4f1\uacfc \uac19\uc774 \ub9e4\uc6b0 \uad11\ubc94\uc704\ud558\uac8c \uc0ac\uc6a9\ub418\ub294\ub370.. C#\uc73c\ub85c \uc774 SQLite\ub97c \ub2e4\ub8e8\ub294 \ub0b4\uc6a9\uc5d0 \ub300\ud574 \uc815\ub9ac\ub97c \ud574 \ubd05\ub2c8\ub2e4.<\/p>\n<p>C#\uc5d0\uc11c SQLite\ub97c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uba3c\uc800 .NET\uc6a9 SQLite \uc5b4\uc148\ube14\ub9ac \ubaa8\ub4c8\uc744 \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4. S<a href='http:\/\/system.data.sqlite.org\/index.html\/doc\/trunk\/www\/downloads.wiki' >QLite \uacf5\uc2dd \uc0ac\uc774\ud2b8<\/a>\uc5d0\uc11c \uad00\ub828 \ud30c\uc77c\uc744 \uc124\uce58\ud560 \uc218 \uc788\ub294 setup \ud30c\uc77c\uc744 \ubc1b\uc544 \uc124\uce58\ud558\uae30 \ubc14\ub78d\ub2c8\ub2e4.<\/p>\n<p>\uac1c\ubc1c\uc744 \uc704\ud574 \ud544\uc694\ud55c \ud30c\uc77c\uc774 \uc124\uce58\ub418\uba74 Visual Studio\uc5d0\uc11c C# \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud558\uace0 \uc544\ub798\uc758 \ud654\uba74\ucc98\ub7fc \uc5b4\uc148\ube14\ub9ac \ucc38\uc870\ub97c \ucd94\uac00\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1238307970.png\" \/><\/p>\n<p>\uc704\uc758 \ud654\uba74\uc5d0\uc11c \ucd94\uac00\ud55c System.Data.SQLite \ucc38\uc870\ub294 SQLite\ub97c \uc704\ud55c ADO.NET \ub370\uc774\ud130 \uc81c\uacf5\uc790(Data Provider)\uc785\ub2c8\ub2e4. \uc774 \ucc38\uc870\ub294 \uc55e\uc11c \uc124\uce58\ub41c \ud3f4\ub354\uc5d0 System.Data.SQLite.dll \ud30c\uc77c\uc744 \ud1b5\ud574 \ucd94\uac00\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\ucc38\uc870\ub97c \ucd94\uac00\ud588\uc73c\ubbc0\ub85c \ucf54\ub4dc\uc5d0\uc11c \ucc38\uc870\uc640 \uad00\ub828\ub41c \ud074\ub798\uc2a4\ub97c \ube60\ub974\uac8c \uc811\uadfc\ud558\uae30 \uc704\ud55c \uc544\ub798\uc758 using \ubb38\uc744 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nusing System.Data.SQLite;\r\n<\/pre>\n<p>\uc774\uc81c \ub2e4\uc74c\uacfc \uac19\uc740 \ud3fc\uc744 \ub514\uc790\uc778\ud568\uc73c\ub85c\uc368 SQLite\uc5d0 \ub300\ud55c \uc8fc\uc694 \ub0b4\uc6a9\uc5d0 \ub300\ud55c \ucf54\ub4dc\ub97c \uc0b4\ud3b4 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1179128303.png\" \/><\/p>\n<p>\ud3fc \uc0c1\uc5d0 \ubc84\ud2bc\uc758 \uc81c\ubaa9\uc744 \ud1b5\ud574 \uc6b0\ub9ac\uac00 \ud30c\uc545\ud560 SQLite\uc5d0 \ub300\ud55c \ucf54\ub4dc\uac00 \ubb34\uc5c7\uc778\uc9c0 \uc9d0\uc791\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc989, \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<ol>\n<li>Create DB File &#8211; SQLite DB \ud30c\uc77c\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/li>\n<li>Open DB &#8211; \uc0dd\uc131\ud55c DB \ud30c\uc77c\uc744 \uc0ac\uc6a9\ud558\uae30 \uc704\ud574 \uc5f0\uacb0\ud569\ub2c8\ub2e4.<\/li>\n<li>Create Table &#8211; DB \ud30c\uc77c\uc5d0 \ud14c\uc774\ube14\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/li>\n<li>Insert Row &#8211; \uc0dd\uc131\ud55c \ud14c\uc774\ube14\uc5d0 Row\ub97c \ucd94\uac00\ud569\ub2c8\ub2e4.<\/li>\n<li>Query Data &#8211; \ud14c\uc774\ube14\uc5d0 \uc800\uc7a5\ub41c \ub370\uc774\ud130\ub97c \uc870\ud68c\ud569\ub2c8\ub2e4.<\/li>\n<li>Close Connection &#8211; DB \ud30c\uc77c\uc5d0 \ub300\ud55c \uc5f0\uacb0\uc744 \ub2eb\uc2b5\ub2c8\ub2e4.<\/li>\n<\/ol>\n<p>\uba3c\uc800 SQLite DB \ud30c\uc77c\uc744 \uc0dd\uc131\ud558\ub294 \ubc84\ud2bc\uc5d0 \ub300\ud55c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nSQLiteConnection.CreateFile(\"c:\/a.sqlite\");\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uac00 \uc131\uacf5\ud55c\ub2e4\uba74 C:\\ \uacbd\ub85c\uc5d0 a.sqlite\ub77c\ub294 \ud30c\uc77c\uc774 \uc0dd\uc131\ub420 \uac83\uc785\ub2c8\ub2e4. \ub2e4\uc74c\uc740 \uc0dd\uc131\ud55c DB \ud30c\uc77c\uc744 \uc0ac\uc6a9\ud558\uae30 \uc704\ud574 \uc5f0\uacb0\ud558\ub294 \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nconn = new SQLiteConnection(\"Data Source=c:\/a.sqlite;Version=3;\");\r\nconn.Open();\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0\uc11c conn \ubcc0\uc218\ub294 \ub2e4\uc74c\uacfc \uac19\uc774 \uc815\uc758\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nprivate SQLiteConnection conn = null;\r\n<\/pre>\n<p>\uc774\uc81c \ub2e4\uc74c\uc740 DB \ud30c\uc77c\uc5d0 \ud14c\uc774\ube14\uc744 \uc0dd\uc131\ud558\ub294 \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nstring sql = \"create table members (name varchar(20), age int)\";\r\n\r\nSQLiteCommand command = new SQLiteCommand(sql, conn);\r\nint result = command.ExecuteNonQuery();\r\n\r\nsql = \"create index idx01 on members(name)\";\r\ncommand = new SQLiteCommand(sql, conn);\r\nresult = command.ExecuteNonQuery();\r\n<\/pre>\n<p>\uc6b0\ub9ac\uac00 \ud754\ud788 \uc54c\uace0 \uc788\ub294 CREATE SQL \ubb38\uc744 \ud1b5\ud574 \ud14c\uc774\ube14\uc744 \uc0dd\uc131\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \ucd94\uac00\uc801\uc73c\ub85c \uc778\ub371\uc2a4(INDEX)\uae4c\uc9c0\ub3c4 \uc0dd\uc131\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uc774\uc81c \ub2e4\uc74c\uc740 \uc0dd\uc131\ud55c \ud14c\uc774\ube14\uc5d0 Row\ub97c \ucd94\uac00\ud558\ub294 \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nString sql = \"insert into members (name, age) values ('\uae40\ub3c4\ud604', 6)\";\r\n\r\nSQLiteCommand command = new SQLiteCommand(sql, conn);\r\nint result = command.ExecuteNonQuery();\r\n<\/pre>\n<p>\uc544.. \uc6b0\ub9ac \uc640\uc774\ud504 \ucf54\uace0\ub294 \uc18c\ub9ac\uac00 \ub4e4\ub9ac\ub124\uc694.. -_-; \uc5ec\ud2bc.. \uc704\uc758 \ucf54\ub4dc\ub97c \ubcf4\uba74 Row\ub97c \ucd94\uac00\ud558\uae30 \uc704\ud574 \ud754\ud788 \uc54c\uace0 \uc788\ub294 INSERT SQL\ubb38\uc744 \uc0ac\uc6a9\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc740 \ud14c\uc774\ube14\uc5d0 \uc800\uc7a5\ub41c \ub370\uc774\ud130\uc5d0 \ub300\ud55c \uc870\ud68c \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nString sql = \"select * from members\";\r\n\r\nSQLiteCommand cmd = new SQLiteCommand(sql, conn);\r\nSQLiteDataReader rdr = cmd.ExecuteReader();\r\nwhile (rdr.Read()) {\r\n    MessageBox.Show(rdr[\"name\"] + \" \" + rdr[\"age\"]);\r\n}\r\n\r\nrdr.Close();\r\n<\/pre>\n<p>SELECT SQL\ubb38\uc744 \ud1b5\ud574 \uc870\ud68c\ud560 \uc218 \uc788\uc73c\uba70, SQLiteDataReader \ud074\ub798\uc2a4\ub97c \ud1b5\ud574 \uc2e4\uc81c \uc870\ud68c\ub41c \ub370\uc774\ud130\ub97c \ud544\ub4dc\ubcc4\ub85c \uc77d\uc5b4 \ub0bc \uc218 \uc788\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774\uc81c \ub05d\uc73c\ub85c DB\uc5d0 \uc5f0\uacb0\ub41c Connection \uac1d\uccb4\ub97c \ub2eb\ub294 \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nconn.Close();\r\n<\/pre>\n<p>\uc790, \uc774\uc0c1\uc73c\ub85c \uc694\uae34\ud558\uac8c \ubc14\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 Local DBMS\uc778 SQLite\ub97c C#\uc5d0\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \ucd5c\uc18c\ud55c\uc758 \ub0b4\uc6a9\uc744 \uc815\ub9ac\ud574 \ubcf4\uc558\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uba54\ubaa8\ub9ac \uae30\ubc18\uc5d0\uc11c \uc790\ub8cc\ub97c \ub2e4\ub8e8\uae30 \uc704\ud574 Array\ub098 Linked List \uadf8\ub9ac\uace0 Hashmap \ub4f1\uc744 \uc0ac\uc6a9\ud558\uc9c0\ub9cc, \ub300\uc6a9\ub7c9 \ub610\ub294 SQL \ubb38\uc744 \ud1b5\ud55c \ub2e4\uc591\ud55c \uc870\uac74\uac80\uc0c9\uc744 \uc704\ud574 DBMS\uc744 \uc0ac\uc6a9\ud574\uc57c\ud560 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc124\uce58\ub3c4 \ud544\uc694\uc5c6\uace0 \uac00\ubccd\uace0 \ube60\ub974\uac8c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 Local DBMS\ub85c SQLite\ub294 \uc548\ub4dc\ub85c\uc774\ub4dc\ub098 SVN \ub4f1\uacfc \uac19\uc774 \ub9e4\uc6b0 \uad11\ubc94\uc704\ud558\uac8c \uc0ac\uc6a9\ub418\ub294\ub370.. C#\uc73c\ub85c \uc774 SQLite\ub97c \ub2e4\ub8e8\ub294 \ub0b4\uc6a9\uc5d0 \ub300\ud574 \uc815\ub9ac\ub97c \ud574 \ubd05\ub2c8\ub2e4. C#\uc5d0\uc11c SQLite\ub97c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uba3c\uc800 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=2290\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C#\uc73c\ub85c SQLite \ub2e4\ub8e8\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[14,109],"class_list":["post-2290","post","type-post","status-publish","format-standard","hentry","category-opensource","tag-c","tag-sqlite"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2290"}],"version-history":[{"count":3,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2290\/revisions"}],"predecessor-version":[{"id":10304,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2290\/revisions\/10304"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2290"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}