{"id":5438,"date":"2012-09-27T16:09:29","date_gmt":"2012-09-27T07:09:29","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=5438"},"modified":"2017-07-16T11:08:00","modified_gmt":"2017-07-16T02:08:00","slug":"cbuilder-xe3%e3%81%a7sqlite%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=5438","title":{"rendered":"C++Builder XE3\u3067SQLite\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002"},"content":{"rendered":"<p><a href=\"http:\/\/cc.embarcadero.com\/item\/29052\">RAD Studio XE3 Hotfix 3<\/a>\u306b\u3088\u3063\u3066Professional edition\u3067SQLite\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>Python\u3067\u30b5\u30f3\u30d7\u30eb\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306f\u300cC:&#92;test&#92;test.db\u300d\u306b\u914d\u7f6e\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre><code>#!python2.7\n# -*- coding: utf-8 -*-\nimport sqlite3\n\ncon = sqlite3.connect(u\"test.db\", isolation_level=None)\ncon.execute(u\"create table example (id integer, name varchar(20))\")\ncon.executemany(u\"insert into example values (?, ?)\",\n        [(1, u\"Delphi XE3\"), (2, u\"C++Builder XE3\"), (3,u\"HTML5 Builder\"),\n         (4, u\"\u30c7\u30eb\u30d5\u30a1\u30a4\"), (5, u\"\u30b7\u30fc\u30d7\u30e9\u30b9\u30d7\u30e9\u30b9\")])\n\nc = con.cursor()\nc.execute(u\"select* from example\")\nfor row in c:\n    print row[0], row[1]\ncon.close()\n<\/code><\/pre>\n<p><a href=\"http:\/\/docwiki.embarcadero.com\/RADStudio\/ja\/%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB%EF%BC%9ASQLite_%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%81%AB%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B%EF%BC%88Delphi%EF%BC%89\">\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\uff1aSQLite \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\uff08Delphi\uff09<\/a>\u306e\u624b\u9806\u306b\u3057\u305f\u304c\u3063\u3066\u64cd\u4f5c\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0015.gif\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0015-300x226.gif?resize=300%2C226\" alt=\"\" title=\"001\" width=\"300\" height=\"226\" class=\"alignnone size-medium wp-image-5440\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0015.gif?resize=300%2C226&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0015.gif?w=334&amp;ssl=1 334w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>SQLConnection1\u306eDriver\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u7de8\u96c6\u3059\u308b\u3068\u304d\u306b\u300cDriver\/Connection \u30ec\u30b8\u30b9\u30c8\u30ea<br \/>\n\u30d5\u30a1\u30a4\u30eb &#8216;C:&#92;\uff5e&#92;dbxconnections.ini&#8217; \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u300d\u3068\u3044\u3046\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc<br \/>\n\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u5834\u5408\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u5834\u6240\u306b\u7a7a\u306edbxconnections.ini\u3092\u4f5c\u6210\u3059\u308b\u3068\u3044\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u6642\u306b\u300csqlite3.dll\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u300d\u3068\u3044\u3046\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u5834<br \/>\n\u5408\u306f\u3001<a href=\"http:\/\/www.sqlite.org\/download.html\">SQLite\u306e\u30da\u30fc\u30b8<\/a>\u304b\u3089sqlite3.dll\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u30d1\u30b9\u306e\u901a\u3063\u305f\u5834\u6240\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u6642\u306e\u753b\u9762<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0005.gif\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0005-300x226.gif?resize=300%2C226\" alt=\"\" title=\"000\" width=\"300\" height=\"226\" class=\"alignnone size-medium wp-image-5441\" srcset=\"https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0005.gif?resize=300%2C226&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.gesource.jp\/weblog\/wp-content\/uploads\/2012\/09\/0005.gif?w=334&amp;ssl=1 334w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>C++Builder XE3\u3067\u8a18\u8ff0\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/p>\n<pre><code>void __fastcall TForm1::connectButtonClick(TObject *Sender)\n{\n  SQLConnection1-&gt;ConnectionName = \"C:\\\\test\\\\test.db\";\n  SQLConnection1-&gt;Params-&gt;Add(\"Database=C:\\\\test\\\\test.db\");\n  try {\n    SQLConnection1-&gt;Connected = true;\n    executeButton-&gt;Enabled = true;\n    outputMemo-&gt;Text = \"Connection established!\";\n  } catch (EDatabaseError&amp; E) {\n    ShowMessage(\"Exception raised with message: \" + E.Message);\n  }\n}\nvoid __fastcall TForm1::executeButtonClick(TObject *Sender)\n{\n  outputMemo-&gt;Clear();\n  UnicodeString query = \"SELECT * FROM example;\";\n  TDataSet* results;\n  try {\n    SQLConnection1-&gt;Execute(query, NULL, results);\n  } catch (Exception&amp; E) {\n    outputMemo-&gt;Text = \"Exception raised with message: \" + E.Message;\n  }\n  ShowSelectResults(results);\n}\nvoid TForm1::ShowSelectResults(TDataSet* results)\n{\n  if (!results-&gt;IsEmpty()) {\n    TStringList* names = new TStringList();\n    results-&gt;GetFieldNames(names);\n    for (results-&gt;First(); !results-&gt;Eof; results-&gt;Next()) {\n      UnicodeString currentLine;\n      for (int i = 0; i &lt; names-&gt;Count; ++i) {\n        TField* currentField = results-&gt;FieldByName(names-&gt;Strings[i]);\n        currentLine = currentLine + \" \" + currentField-&gt;AsString;\n      }\n      outputMemo-&gt;Lines-&gt;Add(currentLine);\n    }\n    delete names;\n  }\n}\n<\/code><\/pre>\n<p><iframe src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&#038;bc1=FFFFFF&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=gesource-22&#038;o=9&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=479811944X\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RAD Studio XE3 Hotfix 3\u306b\u3088\u3063\u3066Professional edition\u3067SQLite\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002 Python\u3067\u30b5\u30f3\u30d7\u30eb\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u4f5c\u6210\u3057\u305f &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=5438\" class=\"more-link\">Continue reading &lsquo;C++Builder XE3\u3067SQLite\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16],"tags":[149,47,42,44],"class_list":["post-5438","post","type-post","status-publish","format-standard","hentry","category-cbuilder","tag-cbuilder","tag-sqlite","tag-tips","tag-vcl"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/5438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5438"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/5438\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}