All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
Decimal type support (#203).
-
UUID type support (#202).
-
Datetime type support and tarantool.Datetime type (#204).
Tarantool datetime objects are decoded to
tarantool.Datetimetype.tarantool.Datetimemay be encoded to Tarantool datetime objects.You can create
tarantool.Datetimeobjects either from msgpack data or by using the same API as in Tarantool:dt1 = tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, sec=54, nsec=308543321) dt2 = tarantool.Datetime(timestamp=1661969274) dt3 = tarantool.Datetime(timestamp=1661969274, nsec=308543321)
tarantool.Datetimeexposesyear,month,day,hour,minute,sec,nsec,timestampandvalue(integer epoch time with nanoseconds precision) properties if you need to converttarantool.Datetimeto any other kind of datetime object:pdt = pandas.Timestamp(year=dt.year, month=dt.month, day=dt.day, hour=dt.hour, minute=dt.minute, second=dt.sec, microsecond=(dt.nsec // 1000), nanosecond=(dt.nsec % 1000))
-
Offset in datetime type support (#204).
Use
tzoffsetparameter to set up offset timezone:dt = tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, sec=54, nsec=308543321, tzoffset=180)
You may use
tzoffsetproperty to get timezone offset of a datetime object. -
Timezone in datetime type support (#204).
Use
tzparameter to set up timezone name:dt = tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, sec=54, nsec=308543321, tz='Europe/Moscow')
If both
tzandtzoffsetis specified,tzis used.You may use
tzproperty to get timezone name of a datetime object. -
Datetime interval type support and tarantool.Interval type (#229).
Tarantool datetime interval objects are decoded to
tarantool.Intervaltype.tarantool.Intervalmay be encoded to Tarantool interval objects.You can create
tarantool.Intervalobjects either from msgpack data or by using the same API as in Tarantool:di = tarantool.Interval(year=-1, month=2, day=3, hour=4, minute=-5, sec=6, nsec=308543321, adjust=tarantool.IntervalAdjust.NONE)
Its attributes (same as in init API) are exposed, so you can use them if needed.
-
Datetime interval arithmetic support (#229).
Valid operations:
tarantool.Datetime+tarantool.Interval=tarantool.Datetimetarantool.Datetime+tarantool.Interval=tarantool.Datetimetarantool.Datetime-tarantool.Datetime=tarantool.Intervaltarantool.Interval+tarantool.Interval=tarantool.Intervaltarantool.Interval-tarantool.Interval=tarantool.Interval
Since
tarantool.Intervalcould containmonthandyearfields and such operations could be ambiguous, you can useadjustfield to tune the logic. The behavior is the same as in Tarantool, see Interval arithmetic RFC.-
tarantool.IntervalAdjust.NONE-- only truncation toward the end of month performed (default mode).>>> dt = tarantool.Datetime(year=2022, month=3, day=31) datetime: Timestamp('2022-03-31 00:00:00'), tz: "" >>> di = tarantool.Interval(month=1, adjust=tarantool.IntervalAdjust.NONE) >>> dt + di datetime: Timestamp('2022-04-30 00:00:00'), tz: ""
-
tarantool.IntervalAdjust.EXCESS-- overflow mode, without any snap or truncation to the end of month, straight addition of days in month, stopping over month boundaries if there is less number of days.>>> dt = tarantool.Datetime(year=2022, month=1, day=31) datetime: Timestamp('2022-01-31 00:00:00'), tz: "" >>> di = tarantool.Interval(month=1, adjust=tarantool.IntervalAdjust.EXCESS) >>> dt + di datetime: Timestamp('2022-03-02 00:00:00'), tz: ""
-
tarantool.IntervalAdjust.LAST-- mode when day snaps to the end of month, if happens.>>> dt = tarantool.Datetime(year=2022, month=2, day=28) datetime: Timestamp('2022-02-28 00:00:00'), tz: "" >>> di = tarantool.Interval(month=1, adjust=tarantool.IntervalAdjust.LAST) >>> dt + di datetime: Timestamp('2022-03-31 00:00:00'), tz: ""
- Bump msgpack requirement to 1.0.4 (PR #223). The only reason of this bump is various vulnerability fixes, msgpack>=0.4.0 and msgpack-python==0.4.0 are still supported.
- SSL support (PR #220, #217).
- Tarantool Enterprise testing workflow on GitHub actions (PR #220).
-
Reusable testing workflow for integration with tarantool artifacts (PR #192).
-
Connection pool with master discovery (PR #207, #196).
ConnectionPool is supported only for Python 3.7 or newer. Authenticated user must be able to call
box.infoon instances. For example, to give grants to'guest'user, evaluatebox.schema.func.create('box.info') box.schema.user.grant('guest', 'execute', 'function', 'box.info')
on Tarantool 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. The user does not need to use any synchronization mechanisms in requests, it's all handled with ConnectionPool methods.
ConnectionPool API is the same as the plain Connection API. On each request, a connection is chosen to execute the request. A connection is chosen based on the request mode:
Mode.ANYchooses any instance.Mode.RWchooses an RW instance.Mode.ROchooses an RO instance.Mode.PREFER_RWchooses an RW instance, if possible, an RO instance otherwise.Mode.PREFER_ROchooses an RO instance, if possible, an RW instance otherwise. All requests that guarantee to write data (insert, replace, delete, upsert, update) use the RW mode by default. The select request usesANYby default. You can set the mode explicitly. The call, eval, execute, and ping requests require to set the mode explicitly.
Example:
pool = tarantool.ConnectionPool( addrs=[ {'host': '108.177.16.0', 'port': 3301}, {'host': '108.177.16.0', 'port': 3302}, ], user='test', password='test',) pool.call('some_write_procedure', arg, mode=tarantool.Mode.RW)
-
Breaking change: Python 2 support dropped (PR #207).
-
Breaking change:
encode/decodebinary types for Python 3 changed to support working withvarbinary(PR #211, #105). With Python 2, the behavior of the connector remains the same.Before this patch:
-
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
Several method (delete, update, select) did not support using
bytesas key.After this patch:
-
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
All methods now support using
bytesas key.Thus, an
encoding="utf-8"connection may be used to work with UTF-8 strings andvarbinary, and anencoding=Noneconnection may be used to work with non-UTF-8 strings. -
-
Clarify the license of the project (BSD-2-Clause) (PR #210, #197).
-
Migrate CI to GitHub Actions (PR #213, PR #216, #182).
-
Various improvements and fixes in README (PR #210, PR #215).
- json.dumps compatibility with Python 2 (PR #186).
- Unix socket support in mesh_connection (PR #189, #111).
- Various fixes in tests (PR #189, #111, PR #195, #194).
- msgpack library dependency (PR #185).
Caution: Use tarantool-python 0.7.1 instead of 0.7.0. It fixes the dependency on the msgpack library.
- Support msgpack 1.0.0 (#155, PR #173).
- SQL support (the method
<connection>.execute()) (#159, PR #161). - Allow receiving a Tarantool tuple as a Python tuple, not a list, with
the
use_list=Falseconnection option (#166, PR #161). - Support the Database API (PEP-0249) (PR #161).
- Various improvements in README (PR #147, PR #151, PR #180).
- Support
encoding=Noneconnections (PR #172). - Various improvements and fixes in tests (8ff9a3f, bd37703, PR #165, #178, PR #179, PR #181).