| = Ignite for Python |
| |
| This chapter explains system requirements for running Ignite and how to install Ignite, start a cluster, and run a simple Hello World example using a thin link:thin-clients/python-thin-client[client for Python]. |
| |
| Thin Client is a lightweight Ignite connection mode. It does not participate in the cluster, never holds any data, or performs computations. |
| All it does is establish a socket connection to one or multiple Ignite nodes and perform all operations through those nodes. |
| |
| == Prerequisites |
| |
| Ignite was tested on: |
| |
| include::includes/prereqs.adoc[] |
| |
| and: |
| |
| [cols="1,3"] |
| |======================================================================= |
| |Python |Version 3.4 or above |
| |======================================================================= |
| |
| == Installing Ignite |
| |
| include::includes/install-ignite.adoc[] |
| |
| Once that's done, execute the following command to install the Python Thin Client package. |
| This thin client is abbreviated as `pyignite`: |
| |
| include::includes/install-python-pip.adoc[] |
| |
| == Starting a Node |
| |
| Before connecting to Ignite via the Python thin client, you must start at least one Ignite cluster node. |
| |
| include::includes/starting-node.adoc[] |
| |
| == Running Your First Application |
| |
| Once the cluster is started, you can use the Ignite Python thin client to perform cache operations. |
| |
| Assuming that the server node is running locally, here is a _HelloWorld_ example that puts and gets values from the cache: |
| |
| .hello.py |
| [source,python] |
| ---- |
| from pyignite import Client |
| |
| client = Client() |
| client.connect('127.0.0.1', 10800) |
| |
| #Create cache |
| my_cache = client.create_cache('my cache') |
| |
| #Put value in cache |
| my_cache.put(1, 'Hello World') |
| |
| #Get value from cache |
| result = my_cache.get(1) |
| print(result) |
| ---- |
| |
| To run this, you can save the example as a text file (hello.py for example) and run it from the command line: |
| |
| |
| [source, python] |
| ---- |
| python3 hello.py |
| ---- |
| |
| Or you can enter the example into your Python interpreter/shell (IDLE on Windows, for example) and modify/execute it there. |
| |
| |
| == Further Examples |
| |
| Explore more Ignite Python examples link:{githubUrl}/modules/platforms/python/examples[here^]. |