I heard this story at the hackathon the other day and decided to use it immediately How about the details ... http://petitviolet.hatenablog.com/entry/20141011/1413037537
I tried the following command in How I've done it before, but it didn't work.
curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
After all, it is listed on this site
$sudo apt-get install python-pip
I was able to install pip with.
However, it cannot be installed due to a version problem ... I'll give you the Python version of Raspberry Pi in the first place
The update was done with reference to this article.
The version was upgraded by entering the following command group.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
cd ~
wget https://www.python.org/ftp/python/2.7.7/Python-2.7.7.tgz
tar -zxvf Python-2.7.7.tgz
cd Python-2.7.7
./configure
make -j 4
sudo make install
Reboot after update
sudo reboot
Check the version after rebooting
python -V
When you hit
Python 2.7.7
You can see that it is installed correctly
wget https://bootstrap.pypa.io/get-pip.py
sudo python2 get-pip.py
Now you are ready for pip
sudo pip install py_nifty_cloud
Also, preparation for initialization (signature generation). This module seems to read the yaml file application key and client key, so prepare it. In the following form ...
nifty_cloud.yml
APPLICATION_KEY: 'your application key'
CLIENT_KEY: 'your client key'
Write the code for writing to the database as follows
ncmb_post.py
#import
from py_nifty_cloud.nifty_cloud_request import NiftyCloudRequest
# instanciate with yaml file contains APPLICATION KEY and CLIENT KEY
ncr = NiftyCloudRequest('./nifty_cloud.yml')
path = '/classes/TestClass'
method = 'POST'
# post a new recode
values = {'key': 'test'}
response = ncr.post(path=path, query=values)
print(response.status_code)
When executed, it will be as shown in the figure below
In addition, the following warning appears on the command screen.
InsecurePlatformWarning
It seems that it will come out by all means ...
Similarly, the code to pull out is as follows
ncmb_get.py
#import
from py_nifty_cloud.nifty_cloud_request import NiftyCloudRequest
# instanciate with yaml file contains APPLICATION KEY and CLIENT KEY
ncr = NiftyCloudRequest('./nifty_cloud.yml')
path = '/classes/TestClass'
query = {'where' : {'key': 'test'}}
method = 'GET'
# standard way to request
# get recodes which matches a query from path, with GET or POST or PUT http method
response = ncr.request(path=path, query=query, method=method)
type(response)
# >>> requests.models.Response
# show status code
print(response.status_code)
# show response as json format
print(response.json())
The result is below
200
{u'results': [{u'key': u'test', u'createDate': u'2015-10-04T12:17:49.729Z', u'updateDate': u'2015-10-04T12:17:49.730Z', u'objectId': u'mVgYUeowLXFuEQ0R', u'acl': {u'*': {u'read': True, u'write': True}}}]}
Recommended Posts