1. Perl RDBMS Programming id:karupanerura DBI DBIx::* SQL::* etc... 13å¹´3æ23æ¥åææ¥ 2. about.me id:karupanerura ããã±ããã web engineer c/js/perl/elisp ããããHæ¬èªãã§ã MF 13å¹´3æ23æ¥åææ¥
å®éã°ã°ãã°æ£è§£ã¯ãã£ã±ãåºã¦ãããããã«èªåãã³ã¡ã³ãã§æ¸ãã¦ãããã¦ãã¾ããæ¸ãå¿ è¦ããªãããªã¨æã£ã¦ããã©ä¸å¿èªåã®ããã°ã§ãã¾ã¨ãã¦ããã¨ãããã¨ã§ã ä¸è¬çãªè§£ DBIx::Connectorã¨ãDBIx::Handlerçµç±ã§ããªãã$dbhãåå¾ãã¦ããDBIã使ãã ãããã¯fork-safeãªORM(DBIx::Class, DBIx::Skinny, Teng)ã使ãã DBIãç´æ¥ä½¿ã£ã¦ããå ´å ä¸è¬çãªã³ãã¯ã·ã§ã³ãä¿æããã¯ã©ã¤ã¢ã³ãã¨åæ§ã«DBIãforkããåä¾ã親ã®ã³ãã¯ã·ã§ã³ããã®ã¾ã¾ä½¿ããã¨ã¯ãã°ã®åå ã«ãªãã¾ããç¹ã«ãã©ã³ã¶ã¯ã·ã§ã³ã®å¦ççã§é大ãªåé¡ãèµ·ããå¯è½æ§ãããã 解決çã¯ã DBIã®ã³ãã¯ã·ã§ã³ã親ã§ä½ããªãã§ãåä¾ã§ç¬èªã«ä½ã 親ã§ä½ã£ã¦ãã¾ã£ãã³ãã¯ã·ã§ã³ãåä¾ãå®å ¨ã«DESTROYããåæ¥ç¶ãã ã®ã©ã¡ããã«ãªãã¾ããããã§åé¡ã¯2ã§
Mojolicious::Liteã¯ä¸ã¤ã®ãã¡ã¤ã«ã®ä¸ã«å ¨é¨çªã£è¾¼ãã§Webã¢ããªãä½ããã¨ãããã¨ãªã®ã§ãä»èªåãæ°ã«ãªã£ã¦ããã®ãç¿ä½ã®æå³ãè¾¼ãã¦å ¨é¨è©°ãè¾¼ãã§CRUDã¢ããªãä½ã£ã¦ã¿ã¾ãããjQueryãå ¥ãããã£ããã©æ¸ãã¦ãã¦ã«ãªã¹ã«ãªã£ãã®ã§SNBinderã®è£å©ã¨ãã¼ã¸ã£ä»¥å¤ã¯ç¡ãã«ãã¾ããã è²ã çªã£è¾¼ãã§ã¿ããã®ã¯ä»¥ä¸ Teng ãã¼ã¸ã£ï¼ãã©ã°ã¤ã³ï¼ inflate/deflate triggerã®ä»£æ¿ Class::Method::Modifiers Devel::KYTProf Xslate Mojolicious::Liteã§ç¶æ¿ SNBinder ã³ã³ã»ãã éæ Teng nekokakããä½ã®è»½éORMã§ããTengã Skinnyã®å¾ç¶ DBIã®èãã©ããã¼ ã¨ãããã¨ã§ãã·ã³ãã«ããæ®ãã¤ã¤ããã£ã¨æ¸ããããã¨ã¯ããã£ã¨æ¸ããããã«é æ ®ããã¦ã¦è¯ãæã
Perl ã§DB ä»å¹´ã«å ¥ã£ã¦ããã¾ãPerl ã使ããã¨ãå¤ããªã£ã¦ãã¦ãã¾ãããç»é¢ãä¼´ããã®ã¯ã ãããPHP ã§æ¸ãã¦ãããã§ãªããã®ãä¾ãã°ãããå¦çã®ãããªãã®ã¯Perl ã§æ¸ããã¨ãå¤ãã®ã§ãããããæ¸ããã¨ãå¤ããªã£ã¦ãã¦ããã¨ãããã¨ã§ãã Perl ã§DB ãæ±ãã¨ãã¯ãå°ãåã¾ã§ã¯DBIx::Class ã好ãã§ä½¿ã£ã¦ããã®ã§ãæ¢åã®æ¡ä»¶ã®ã«ã¹ã¿ãã¤ãºãªã©ã§ã¯ãã¾ã使ããã¨ã«ãªã£ã¦ãã¾ããããããæ°è¦ã«ä½ãä½ããã¨æãã¨ãã¹ãã¼ããä½ãã®ãé¢åã«æãã¦ãªãã¾ãããã¯ã³ã©ã¤ãã¼ã§ä½ããã®ã§ããããããããé¢åã«æãã¦ãã¦ãã¾ãã¾ããã ãããããç°¡åãªå¦çããããªãã®ã§ããã°ãDBIlC ã¯å¤§è¢è£ãªæ°ããã¦ãã¾ãã¾ããDBIx::Skinny ãªã©ãæ¤è¨ããã®ã§ãããããããO/Rãããã¼ãä¸è¦ãªããããªããã¨ãããããã®å°ããªè¦æ¨¡ã§ã¯ããããããã®ããã¾ã使ãæ°ã«ãªãã¾
å ãã¿ï¼http://d.hatena.ne.jp/tokuhirom/20110104/1294170319 æè¯ãORMã使ããã¨ã®ã¡ãªãã㯠SQLãæ¸ããªãã¦ãããªãã ã¤ã¾ãããã°ã©ãã¯SQLè³ãä½ãããããã°ã©ãã«SQLãæ¸ãããªãã ããã°ã©ã ä¸ã«SQLã¨ããå¥ã®æ¦å¿µãã¯ãã£ã¦ããã¨ã³ã¼ããèªã¿é£ããªãã ããã¯ã¨ã³ãã®RDBMSã®å·®ç°ãå¸åãã¦ãããããããã¯ã¨ã³ããæ°ã«ããå¿ è¦ããªãã ããã«ãããã¯ã¨ã³ãã®RDBMSãç°¡åã«åæ¿ãå¯è½ã ããã°ã©ããã«ã«SQLãçµã¿ç«ã¦ãããã ãªã©ã¨è¨ããããã¨ãå¤ãããããªãã§ãããããã å人çã«ã¯æå¾ã®ãããã°ã©ããã«ã«SQLãçµã¿ç«ã¦ããããã¨è¨ãè¦ä»¶ä»¥å¤ã¯å ¨é¨ ééã£ã¦ããã¨æãã¾ãã ã¤ã«å ¨ã¦èªåã®è¦ç¹ãªã ããªã®ã§éãæè¦ãããã§ããããã¨ãæ¿ç¥ã§è¨ãåãã¾ãã SQLãæ¸ããªãã¦ãããªããã¤ã¾ãããã°ã©ãã¯SQLè³ãä½ã
ãã¦ãä»æ¥ã¯ selectcol_arrayref ã§ããæ¨æ¥ãä¼ç¤¾ã®ã°ã«ã¡ãªååã«æãã¦è²°ãã¾ããã ã¡ããã© ç DBI ã¦ã¼ã¶ã¼ã®ããã® DBI Cookbook (1) - Yet Another Hackadelic ã«ã¦ selectall_arrayref + Slice, selectall_hashref ãªã©ã®ä½¿ãæ¹ãæ¸ãã¾ãããããã¡ããããªã便å©ã CREATE TABLE `application` ( `id` int(10) unsigned NOT NULL, `title` varchar(32) CHARACTER SET sjis NOT NULL, `created_on` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_on` timestamp NOT NULL DEFAULT
Perl 㧠DBIC ã使ç¨ã㦠DB ç³»ã®ããã°ã©ã ãæ¸ãã¨ãã¯ãã¹ãã¼ãã¯ã©ã¹ã®ä½æã®ããã«ããã DBIC::Schema::Loader ã® make_schema_at ã使ã£ã使ãæ¨ã¦ã¹ã¯ãªãããæ¸ãã¦ãã¾ããããããããããããã®å¿ è¦ã¯ãªãã£ãã DBIC::Schema::Loader ã«ã¯ dbicdump ã¨ããã¹ã¯ãªãããä»å±ããã¦ãã¦ãããã使ãã° DB ããã®ã¹ãã¼ãã®èªã¿è¾¼ã¿ãããã³ã¹ãã¼ãã¯ã©ã¹ã®ä½æãå ¨ã¦è¡ã£ã¦ãããã $ dbicdump -o dump_directory=./lib/ My::Schema 'dbi:SQLite:dbname=db/rank.db' $ find lib/My/Schema lib/My/Schema lib/My/Schema/Result lib/My/Schema/Result/Ranking.pm dbicd
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}