Skip to content

Releases: tarantool/tarantool-python

tarantool-python 0.8.0

29 Apr 19:40
Compare
Choose a tag to compare

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 = foo

In 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=None

    Python 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=None

    Python 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).

    ConnectionPool is supported only for Python 3.7 or newer.

    Authenticated user must be able to call box.info on instances.

    ConnectionPool updates 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 with ConnectionPool methods.

    ConnectionPool API 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.ANY chooses any instance.
    • Mode.RW chooses an RW instance.
    • Mode.RO chooses an RO instance.
    • Mode.PREFER_RW chooses an RW instance, if possible, RO instance
      otherwise.
    • Mode.PREFER_RO chooses an RO instance, if possible, RW instance
      otherwise.

    insert, replace, delete, upsert, update use RW mode by default.

    select uses ANY by default.

    call, eval, execute and ping require to set the mode explicitly.

  • [Breaking] varbinary field 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 bytes type as a key for delete, update, select
    (#105, PR #211).

    Now bytes can 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 MeshConnection are 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

  • Fixed formatting and wording in README (PR #215).
  • Clarified license of the project (BSD-2-Clause) (#197, PR #210).

tarantool-python 0.7.1

28 Dec 01:08
Compare
Choose a tag to compare

Overview

It is pure technical release. It fixes the dependency on the msgpack
library.

tarantool-python 0.7.0

28 Dec 00:41
Compare
Choose a tag to compare

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=False connection 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 twine or
    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

14 Jun 21:42
a14e5cf
Compare
Choose a tag to compare

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

  • Fixed the deprecation warning due to deprecated way to import abstract
    collections.
  • Fixed SchemaReloadException raising after reconnection with non-actual
    schema id (#141).
  • Fixed a string representation of a Response object without data (say,
    authentication response) (#139).

tarantool-python 0.6.5

19 Mar 00:49
2bb581a
Compare
Choose a tag to compare
Pre-release

Breaking changes

This release should not break existing code.

New features

  • Added MeshConnection that allows to switch between nodes from a user
    provided list if a current node is down using round-robin strategy (#106).
  • Added connection_timeout parameter to Connection (#115).

Bugfixes

  • Fixed auto-reconnection in Connection.
  • Eliminated deprecation warnings on Python 3 (#114).
  • Added TCP_NODELAY back (it was removed in 0.6.4) (#127).

tarantool-python 0.6.4

11 Apr 14:30
Compare
Choose a tag to compare

Fixes for Windows

tarantool-python 0.6.3

03 Apr 16:26
Compare
Choose a tag to compare

Release for PyPi with fix for Tarantool 1.10.x

tarantool-python 0.6.2

30 Mar 13:29
Compare
Choose a tag to compare

Release for PyPI with new schema type

tarantool-python 0.6.1

23 May 18:04
Compare
Choose a tag to compare

Release for PyPI with some incompatible changes:

  • str/repr of tuples now shows not yaml, but json (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

18 May 20:27
Compare
Choose a tag to compare
tarantool-python 0.5.5