Python example - tsafin/tarantool GitHub Wiki
Here is a complete Python program that inserts ['A','BB']
into space[0]
via the high-level Python API. To prepare, paste the code into a file named example.py
, and install tarantool-python
:
$ pip install tarantool
Before trying to run, check that the server (tarantool_box) is running on localhost (127.0.0.1) and its primary port is the default (33013) and space[0]'s primary key type is string (space[0].index[0].key_field[0].type = "STR" in configuration file).
To run, say python example.py. The program will connect to the server, send the request and won't throw exception if all went well. If the row already exists, the program will throw DatabaseException(“Duplicate key exists in unique index 0”).
#!/usr/bin/python
from tarantool import Connection
c = Connection("127.0.0.1", 33013)
result = c.insert(0, 'A','BB')
print result
The example program only shows one command and does not show all that's necessary for good practice.
For future information, please, read Documentation