I tried pykintone, a Python library for kintone, on Windows Subsystem for Linux. You can use it by installing pykintone with pip3.
Preparation of pykintone usage environment
--Installing pip3 --Installing pykintone
The following is installed by default.
python : python2.7 python3 : python3.4
rex0220@EDGE-E470:~$ ll /usr/bin/python*
lrwxrwxrwx 1 root root 9 December 21 2013/usr/bin/python -> python2.7*
lrwxrwxrwx 1 root root 9 December 21 2013/usr/bin/python2 -> python2.7*
-rwxr-xr-x 1 root root 975 January 2 2014/usr/bin/python2-jsondiff*
-rwxr-xr-x 1 root root 1080 January 2 2014/usr/bin/python2-jsonpatch*
-rwxr-xr-x 1 root root 3345416 June 23 2015/usr/bin/python2.7*
lrwxrwxrwx 1 root root 9 March 23 2014/usr/bin/python3 -> python3.4*
lrwxrwxrwx 1 root root 16 March 23 2014/usr/bin/python3-config -> python3.4-config*
-rwxr-xr-x 2 root root 3693624 November 17 11:31 /usr/bin/python3.4*
lrwxrwxrwx 1 root root 33 November 17 11:31 /usr/bin/python3.4-config -> x86_64-linux-gnu-python3.4-config*
-rwxr-xr-x 2 root root 3693624 November 17 11:31 /usr/bin/python3.4m*
lrwxrwxrwx 1 root root 34 November 17 11:31 /usr/bin/python3.4m-config -> x86_64-linux-gnu-python3.4m-config*
lrwxrwxrwx 1 root root 10 March 23 2014/usr/bin/python3m -> python3.4m*
lrwxrwxrwx 1 root root 17 March 23 2014/usr/bin/python3m-config -> python3.4m-config*
pip3 (Python's package management system) is not installed, so install it.
sudo apt-get install python3-pip
Loading the package list...Done 0%
Creating a dependency tree
Reading status information...Done
...
python3-pip (1.5.4-1ubuntu4)Is set...
python3-wheel (0.24.0-1~ubuntu1)Is set...
libc-bin (2.19-0ubuntu6.9)Processing the trigger of...
which pip3
/usr/bin/pip3
sudo pip3 install pykintone
Downloading/unpacking pykintone
Downloading pykintone-0.3.9.zip
Running setup.py (path:/tmp/pip_build_root/pykintone/setup.py) egg_info for package pykintone
Downloading/unpacking PyYAML (from pykintone)
Downloading PyYAML-3.12.tar.gz (253kB): 253kB downloaded
Running setup.py (path:/tmp/pip_build_root/PyYAML/setup.py) egg_info for package PyYAML
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3/dist-packages (from pykintone)
Downloading/unpacking pytz (from pykintone)
Downloading pytz-2016.10-py2.py3-none-any.whl (483kB): 483kB downloaded
Downloading/unpacking tzlocal (from pykintone)
Downloading tzlocal-1.3.tar.gz
Running setup.py (path:/tmp/pip_build_root/tzlocal/setup.py) egg_info for package tzlocal
Installing collected packages: pykintone, PyYAML, pytz, tzlocal
Running setup.py install for pykintone
Running setup.py install for PyYAML
checking if libyaml is compilable
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c build/temp.linux-x86_64-3.4/check_libyaml.c -o build/temp.linux-x86_64-3.4/check_libyaml.o
build/temp.linux-x86_64-3.4/check_libyaml.c:2:18: fatal error: yaml.h:There is no such file or directory
#include <yaml.h>
^
compilation terminated.
libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
specify the option --include-dirs or uncomment and
modify the parameter include_dirs in setup.cfg)
Running setup.py install for tzlocal
Successfully installed pykintone PyYAML pytz tzlocal
Cleaning up...
Create a record acquisition script according to the sample.
getRec1.py
import pykintone
r = pykintone.app("kintone domain", "APPID", "API token").select("")
if r.ok:
records = r.records
print(records)
else:
print(r.error)
The record was retrieved and displayed on standard output.
python3 getRec1.py
[{'Author': {'value': {'name': 'Alex2013', 'code': 'Alex2013'}, 'type': 'CREATOR'}, 'String A': {'value': 'B02A', 'type': 'SINGLE_LINE_TEXT'}, 'Creation date and time': {'value': '2017-01-26T15:47:00Z', 'type': 'CREATED_TIME'}, 'String B': {'value': 'B02B', 'type': 'SINGLE_LINE_TEXT'}, 'String 2_3': {'value': 'B02C', 'type': 'SINGLE_LINE_TEXT'}, 'changer': {'value': {'name': 'Alex2013', 'code': 'Alex2013'}, 'type': 'MODIFIER'}, 'String 2_2': {'value': 'B02B', 'type': 'SINGLE_LINE_TEXT'}, 'Record number': {'value': '2', 'type': 'RECORD_NUMBER'}, 'String 1_1': {'value': 'A02A', 'type': 'SINGLE_LINE_TEXT'}, 'Update date and time': {'value': '2017-01-26T23:49:00Z', 'type': 'UPDATED_TIME'}, 'Lookup A': {'value': 'A02', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_3': {'value': 'A02C', 'type': 'SINGLE_LINE_TEXT'}, 'ID': {'value': 'jj', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_4': {'value': 'A02D', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_2': {'value': 'A02B', 'type': 'SINGLE_LINE_TEXT'}, '$revision': {'value': '4', 'type': '__REVISION__'}, 'String 2_4': {'value': 'B02', 'type': 'SINGLE_LINE_TEXT'}, '$id': {'value': '2', 'type': '__ID__'}, 'String C': {'value': 'B02C', 'type': 'SINGLE_LINE_TEXT'}, 'String 2_1': {'value': 'B02A', 'type': 'SINGLE_LINE_TEXT'}, 'Lookup B': {'value': 'B02', 'type': 'SINGLE_LINE_TEXT'}, 'String D': {'value': 'B02', 'type': 'SINGLE_LINE_TEXT'}}, {'Author': {'value': {'name': 'Alex2013', 'code': 'Alex2013'}, 'type': 'CREATOR'}, 'String A': {'value': 'B01A', 'type': 'SINGLE_LINE_TEXT'}, 'Creation date and time': {'value': '2017-01-26T12:06:00Z', 'type': 'CREATED_TIME'}, 'String B': {'value': 'B01B', 'type': 'SINGLE_LINE_TEXT'}, 'String 2_3': {'value': 'B01C', 'type': 'SINGLE_LINE_TEXT'}, 'changer': {'value': {'name': 'Alex2013', 'code': 'Alex2013'}, 'type': 'MODIFIER'}, 'String 2_2': {'value': 'B01B', 'type': 'SINGLE_LINE_TEXT'}, 'Record number': {'value': '1', 'type': 'RECORD_NUMBER'}, 'String 1_1': {'value': 'A01A', 'type': 'SINGLE_LINE_TEXT'}, 'Update date and time': {'value': '2017-01-26T12:06:00Z', 'type': 'UPDATED_TIME'}, 'Lookup A': {'value': 'A01', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_3': {'value': 'A01C', 'type': 'SINGLE_LINE_TEXT'}, 'ID': {'value': 'C01', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_4': {'value': 'A01D', 'type': 'SINGLE_LINE_TEXT'}, 'String 1_2': {'value': 'A01B', 'type': 'SINGLE_LINE_TEXT'}, '$revision': {'value': '1', 'type': '__REVISION__'}, 'String 2_4': {'value': 'B01D', 'type': 'SINGLE_LINE_TEXT'}, '$id': {'value': '1', 'type': '__ID__'}, 'String C': {'value': 'B01C', 'type': 'SINGLE_LINE_TEXT'}, 'String 2_1': {'value': 'B01A', 'type': 'SINGLE_LINE_TEXT'}, 'Lookup B': {'value': 'B01', 'type': 'SINGLE_LINE_TEXT'}, 'String D': {'value': 'B01D', 'type': 'SINGLE_LINE_TEXT'}}]
Recommended Posts