Releases: tarantool/tarantool-python
tarantool-python 0.8.0
Overview
The most interesting feature offered by this release is connection pool with
automatic master discovery support.
Consider a simple example.
In tarantool:
#!/usr/bin/env tarantool
box.cfg({listen = os.getenv('LISTEN') or 3301})
box.once('init', function()
-- Connection pool calls box.info() to monitor tarantool
-- instances.
box.schema.func.create('box.info')
box.schema.user.grant('guest', 'execute', 'function', 'box.info')
box.schema.space.create('s')
box.space.s:create_index('pk')
box.schema.user.grant('guest', 'read,write', 'space', 's')
box.schema.func.create('foo')
box.schema.user.grant('guest', 'execute', 'function', 'foo')
end)
-- Do a write request.
local function foo(tuple)
box.space.s:replace(tuple)
end
_G.foo = fooIn Python:
#!/usr/bin/env python
import tarantool
# Create a connection pool.
pool = tarantool.ConnectionPool(addrs=[
{'host': '127.0.0.1', 'port': 3301},
{'host': '127.0.0.1', 'port': 3302},
])
# Use the space API.
pool.replace('s', [1, 2, 3])
tuple = pool.select('s', [1])
# Call a function.
pool.call('foo', [[1, 2, 3]], mode=tarantool.Mode.RW)This release also provides more natural mapping of msgpack string/binary types
into Python string/binary types. Now string in tarantool is marshalled
from/to str in Python and varbinary in tarantool is marshalled from/to
bytes in Python. See details below.
Breaking changes
This release keeps existing APIs the same, but there are important
string/binary marshalling changes and Python 2 tear down. We expect that most
of existing code will not require any changes, but, please, take a look on the
information below.
MeshConnection is now considered as deprecated in favor of the newly
introduced ConnectionPool. We will remove MeshConnection in one of future
releases.
Python 2 support was dropped. We test the connector since Python 3.5 to 3.10.
The new connection pool requires Python 3.7 or newer.
Msgpack string/binary types mapping from/to Python types was changed. The
behaviour is the following.
tarantool-python 0.7.1 and older:
-
encoding='utf-8'(default)Python 3 -> Tarantool -> Python 3 str -> mp_str (string) -> str bytes -> mp_str (string) -> str mp_bin (varbinary) -> bytes -
encoding=NonePython 3 -> Tarantool -> Python 3 bytes -> mp_str (string) -> bytes str -> mp_str (string) -> bytes mp_bin (varbinary) -> bytes
tarantool-python 0.8.0 and newer:
-
encoding='utf-8'(default)Python 3 -> Tarantool -> Python 3 str -> mp_str (string) -> str bytes -> mp_bin (varbinary) -> bytes -
encoding=NonePython 3 -> Tarantool -> Python 3 bytes -> mp_str (string) -> bytes str -> mp_str (string) -> bytes mp_bin (varbinary) -> bytes
If you use varbinary for storing binary data (and string for ASCII or
UTF-8 texts), default encoding='utf-8' mode should work fine.
If binary data is stored in string fields, consider encoding=None
parameter.
New features
-
Connection pool with master discovery (#196, PR #207).
ConnectionPoolis supported only for Python 3.7 or newer.Authenticated user must be able to call
box.infoon instances.ConnectionPoolupdates information about each server state (RO/RW) on
initial connect and then asynchronously in separate threads. Application
retries must be written considering the asynchronous nature of cluster state
refresh. User does not need to use any synchronization mechanisms in
requests, it's all handled withConnectionPoolmethods.ConnectionPoolAPI is the same as a plain Connection API. On each request,
a connection is chosen to execute this request. A connection is chosen based
on a request mode:Mode.ANYchooses any instance.Mode.RWchooses an RW instance.Mode.ROchooses an RO instance.Mode.PREFER_RWchooses an RW instance, if possible, RO instance
otherwise.Mode.PREFER_ROchooses an RO instance, if possible, RW instance
otherwise.
insert,replace,delete,upsert,updateuse RW mode by default.selectuses ANY by default.call,eval,executeandpingrequire to set the mode explicitly. -
[Breaking]
varbinaryfield type is now fully supported and does not
fail on decoding of non-UTF-8 data (#105, PR #211).It requires incompatible binary/string marshalling changes. See the
'Breaking changes' section for details. -
Support a value of
bytestype as a key fordelete,update,select
(#105, PR #211).Now
bytescan be used as keys in all methods.
Bugfixes
-
Hold string representation of a response object (PR #186).
We want to keep it the same for different Python versions. It sometimes
useful for writing tests using the connector. -
Unix sockets in
MeshConnectionare now supported (#111, PR #189).It was supported in 0.6.5, but broken then in 0.6.6.
Testing
- Migrated CI to GitHub Actions (#182, PR #213, PR #216).
- Added a workflow for integration testing of tarantool's changes against this
connector (PR #192). - Dropped test-run submodule (#111, PR #189).
- Run SQL tests only on tarantool 2.X (#194, PR #195).
Other
tarantool-python 0.7.1
Overview
It is pure technical release. It fixes the dependency on the msgpack
library.
tarantool-python 0.7.0
Caution: Use tarantool-python 0.7.1 instead of 0.7.0. It fixes
the dependency on the msgpack library.
Overview
This release offers two major features: SQL support and implementation
of the Database API (PEP-0249).
Simple example of using SQL:
#!/usr/bin/env python
# In tarantool console:
#
# tarantool> box.cfg{listen = 'localhost:3301'}
# tarantool> box.schema.user.create('me', {password = 'secret'})
# tarantool> box.schema.user.grant('me','read,write,execute,create,drop,alter','universe')
from pprint import pprint
import tarantool
connection = tarantool.connect(host='localhost', port=3301, user='me', password='secret')
res = connection.execute('SELECT :foo, :bar', {'foo': 5, 'bar': 6})
pprint(res)
# Those properties are None for SELECT, shown for the reference.
print('autoincrement_ids: {}'.format(res.autoincrement_ids))
print('affected_row_count: {}'.format(res.affected_row_count))See the similar example implemented using the Database API on the
wiki page.
The Database API becomes the base for the django-tarantool backend.
Aside of those changes, the release provides compatibility with the new
version of the msgpack library (1.0.0) and fixes several tricky cases
around encoding=None option.
Breaking changes
This release should not break existing code.
New features
- Support msgpack 1.0.0 (#155, PR #173).
- Added SQL support (
<connection>.execute()method) (#159, PR #161). - Allow to receive a Tarantool tuple as a Python tuple, not a list, with
use_list=Falseconnection option (#166, PR #161). - Support the Database API (PEP-0249) (PR #161).
Bugfixes
- schema: support encoding=None connections (PR #172).
Other
Infrastructure, CI / CD, testing, readme, pure development changes,
which do not affect an end user directly.
Note: testing changes that were introduced as part of a feature / a
bugfix are not listed here.
- deployment: fixed README.rst and setup.py points, where
twineor
pypi.org complains (PR #147). - readme: fixed links to tarantool documentation (PR #151).
- test: eliminate deprecated box.cfg options (8ff9a3f, bd37703).
- gitignore: add .idea (e49f5f0).
- ci: dropped Ubuntu Disco, which reaches EOL (21e3ebf).
- ci: added Fedora 30, Ubuntu Eoan and Focal (PR #165).
- ci: deploy to 2_3 and 2_4 repositories (PR #165).
- ci: worked around PyYAML installation problem on AppVeyor (PR #165).
- ci: verify on Python 3.8 (PR #161).
- test: fixed luacheck warnings (#178, PR #179).
- readme: refreshed the description of tarantool features (PR #180).
- test: ensure compatibility with Python 3 for some testing /
documentation building code (PR #181).
tarantool-python 0.6.6
Breaking changes
This release should not break existing code.
New features
- Added ability to configure a MeshConnection object to periodically update
instances list from tarantool (#134).
Bugfixes
tarantool-python 0.6.5
tarantool-python 0.6.4
Fixes for Windows
tarantool-python 0.6.3
Release for PyPi with fix for Tarantool 1.10.x
tarantool-python 0.6.2
Release for PyPI with new schema type
tarantool-python 0.6.1
Release for PyPI with some incompatible changes:
str/reprof tuples now shows not yaml, butjson(incompat)- supports now CALL 1.7.1 by default (incompat)
- added support for unix sockets
- getting rid of six dependency
- packages for centos 6/7 should now be ok
tarantool-python 0.5.5
tarantool-python 0.5.5