{"id":1866,"date":"2019-09-25T13:22:36","date_gmt":"2019-09-25T04:22:36","guid":{"rendered":"http:\/\/idealive.jp\/blog\/?p=1866"},"modified":"2019-09-25T13:22:36","modified_gmt":"2019-09-25T04:22:36","slug":"lambda%e3%81%a7pandasql%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/idealive.jp\/blog\/2019\/09\/25\/lambda%e3%81%a7pandasql%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b\/","title":{"rendered":"Lambda\u3067pandasql\u3092\u4f7f\u7528\u3059\u308b"},"content":{"rendered":"<p>Lambda\u3067pandasql\u3092\u5229\u7528\u3059\u308b\u307e\u3067\u306e\u30e1\u30e2<\/p>\n<p>Lambda\u3067\u306fpandas\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u8aad\u307f\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n\u305f\u3060\u3057\u3001AmazonLinux\u3067\u304b\u305f\u3081\u305fpandas\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u308b\u305f\u3081\u4e0b\u8a18\u3092\u884c\u3046\u3002<\/p>\n<p>\u25c6pandas\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u304b\u305f\u3081\u308b<br \/>\n\u30fbEC2 AmazonLinux\uff08AmazonLinux2\u3067\u306f\u306a\u3044\uff09\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u8d77\u52d5<\/p>\n<p>\uff1d\uff1dEC2\u30b3\u30de\u30f3\u30c9\u3067\u4e8b\u524d\u6e96\u5099\uff1d\uff1d<br \/>\n\u30fbpyenv\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n$ git clone https:\/\/github.com\/yyuu\/pyenv.git ~\/.pyenv<\/p>\n<p>\u30fb\u74b0\u5883\u30d1\u30b9\u8a2d\u5b9a<br \/>\n$ echo &#8216;export PYENV_ROOT=&#8221;$HOME\/.pyenv&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br \/>\n$ echo &#8216;export PATH=&#8221;$PYENV_ROOT\/bin:$PATH&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br \/>\n$ echo &#8216;eval &#8220;$(pyenv init -)&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br \/>\n$ source ~\/.bash_profile<\/p>\n<p>\u30fb\u5fc5\u8981\u306a\u4f9d\u5b58\u95a2\u4fc2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n$ sudo yum install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel -y<\/p>\n<p>\u30fbpython\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08\u4eca\u56de\u306f3.7.2\uff09\u203b\u3053\u3053Lambda\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u5408\u308f\u3055\u306a\u3044\u3068\u52d5\u304b\u306a\u3044<br \/>\n$ pyenv install 3.7.2<\/p>\n<p>\u30fb\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u5207\u308a\u66ff\u3048<br \/>\n$ pyenv global 3.7.2<br \/>\n$ pyenv rehash<\/p>\n<p>\uff1d\uff1dpandas\u30fbpandasql\u3092\u56fa\u3081\u308b==<br \/>\n\u30fb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u7528\u306e\u30d5\u30a9\u30eb\u30c0\u4f5c\u6210<br \/>\n$ mkdir python<\/p>\n<p>\u30fb\u4f5c\u6210\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n(pandasql\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068pandas\u3082\u540c\u6642\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308b)<br \/>\n$ pip install -t .\/python pandasql<\/p>\n<p>\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5727\u7e2e<br \/>\n$ zip -r pandas.zip python<\/p>\n<p>\uff1d\uff1d\u5727\u7e2e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092S3\u3078\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\uff1d\uff1d<br \/>\n\uff08\u203bS3\u306bIAM\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u30fb\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\uff09<br \/>\n\u30fb\u8a8d\u8a3c\u8a2d\u5b9a(\u8a2d\u5b9a\u3057\u305f\u30ad\u30fc\u3092\u8a2d\u5b9a\u3059\u308b)<br \/>\n$ aws configure<br \/>\nAWS Access Key ID [None]: xxxxx<br \/>\nAWS Secret Access Key [None]: yyyyy<br \/>\nDefault region name [None]: zzzzz<br \/>\nDefault output format [None]: \uff08\u4e0d\u8981\u3067\uff2f\uff2b\uff09<\/p>\n<p>\u30fb\u30d5\u30a1\u30a4\u30eb\u3092S3\u3078\u30b3\u30d4\u30fc<br \/>\naws s3 cp {\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9} s3:\/\/{\u30d0\u30b1\u30c3\u30c8\u540d}\/{\u30d1\u30b9}<\/p>\n<p>\u25c6Lambda\u306eLayer\u4f5c\u6210<\/p>\n<p>\u4e0a\u8a18\u3067pandas\u30fbpandasql\u3092zip\u3067\u56fa\u3081\u308c\u305f\u3089\u3001Lambda\u306eLayer\u4f5c\u6210\u3088\u308a\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u884c\u3044Layer\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\nLambda\u4f5c\u6210\u6642\u306b\u4f5c\u6210\u3057\u305fLayer\u3092\u8ffd\u52a0\u3059\u308b\u3068pandas\u3001pandasql\u304cimport\u53ef\u80fd\u306b\u306a\u308b\u3002<\/p>\n<p>\u3042\u3068\u306f\u3001\u30ed\u30b8\u30c3\u30af\u3067\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<p>\u4ee5\u4e0a\u3001\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b\u30e1\u30e2\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lambda\u3067pandasql\u3092\u5229\u7528\u3059\u308b\u307e\u3067\u306e\u30e1\u30e2 Lambda\u3067\u306fpandas\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u8aad\u307f\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308b\u3002 \u305f\u3060\u3057\u3001AmazonLinux\u3067\u304b\u305f\u3081\u305fpandas\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5408\u308f\u305b\u308b\u5fc5\u8981&#8230;<a class=\"read-more-link button\" href=\"https:\/\/idealive.jp\/blog\/2019\/09\/25\/lambda%e3%81%a7pandasql%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":7,"featured_media":1867,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1866","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1866"}],"collection":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/comments?post=1866"}],"version-history":[{"count":1,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1866\/revisions"}],"predecessor-version":[{"id":1868,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1866\/revisions\/1868"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media\/1867"}],"wp:attachment":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media?parent=1866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/categories?post=1866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/tags?post=1866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}