apache-iotdb 2.0.10__tar.gz → 2.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/PKG-INFO +35 -3
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/README.md +34 -2
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/PKG-INFO +35 -3
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/SOURCES.txt +7 -1
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/Session.py +166 -56
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/SessionPool.py +8 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/dbapi/Connection.py +33 -2
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/table_session.py +6 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/table_session_pool.py +4 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/common/constants.py +2 -1
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/common/ttypes.py +385 -99
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/confignode/IConfigNodeRPCService.py +1754 -371
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/confignode/constants.py +2 -1
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/confignode/ttypes.py +1955 -824
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/datanode/IDataNodeRPCService.py +1835 -297
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/datanode/MPPDataExchangeService.py +430 -8
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/datanode/constants.py +2 -1
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/datanode/ttypes.py +1960 -593
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/rpc/IClientRPCService.py +411 -134
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/rpc/constants.py +2 -1
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/rpc/ttypes.py +178 -61
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/BitMap.py +39 -0
- apache_iotdb-2.0.12/iotdb/utils/SessionUtils.py +128 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/Tablet.py +6 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/rpc_utils.py +7 -4
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/pyproject.toml +1 -1
- apache_iotdb-2.0.12/tests/unit/test_rpc_utils.py +56 -0
- apache_iotdb-2.0.12/tests/unit/test_session_connection.py +116 -0
- apache_iotdb-2.0.12/tests/unit/test_session_node_url.py +85 -0
- apache_iotdb-2.0.12/tests/unit/test_session_ssl.py +152 -0
- apache_iotdb-2.0.12/tests/unit/test_session_utils.py +160 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/dependency_links.txt +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/entry_points.txt +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/requires.txt +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/apache_iotdb.egg-info/top_level.txt +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/dbapi/Cursor.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/dbapi/Exceptions.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/dbapi/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/sqlalchemy/IoTDBDialect.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/sqlalchemy/IoTDBIdentifierPreparer.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/sqlalchemy/IoTDBSQLCompiler.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/sqlalchemy/IoTDBTypeCompiler.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/sqlalchemy/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/template/MeasurementNode.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/template/Template.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/template/TemplateNode.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/template/TemplateQueryType.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/template/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/common/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/confignode/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/datanode/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/thrift/rpc/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/common/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/common/constant/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/common/constant/tsfile_constant.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/utils/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/utils/date_utils.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/utils/pair.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/utils/read_write_io_utils.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/tsfile/utils/tsblock_serde.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/Field.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/IoTDBConstants.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/NumpyTablet.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/RowRecord.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/SessionDataSet.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/exception.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/iotdb/utils/iotdb_rpc_dataset.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/setup.cfg +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/dbapi/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/dbapi/test_connection.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/dbapi/test_cursor.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/iotdb_container.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/sqlalchemy/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/sqlalchemy/test_dialect.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/tablet_performance_comparison.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_aligned_timeseries.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_dataframe.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_delete_data.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_new_data_types.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_one_device.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_relational_session.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_session.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_session_pool.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_tablemodel_insert.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_tablemodel_query.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_tablet.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_todf.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/integration/test_treemodel_insert.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/unit/__init__.py +0 -0
- {apache_iotdb-2.0.10 → apache_iotdb-2.0.12}/tests/unit/test_numpy_tablet.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apache-iotdb
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.12
|
|
4
4
|
Summary: Apache IoTDB client API
|
|
5
5
|
Author-email: Apache IoTDB <dev@iotdb.apache.org>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -112,6 +112,40 @@ Notice: this RPC compression status of client must comply with that of IoTDB ser
|
|
|
112
112
|
session.close()
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
### SSL and Mutual TLS
|
|
116
|
+
|
|
117
|
+
Use `use_ssl=True` and `ca_certs` to enable SSL and verify the server certificate.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
session = Session(
|
|
121
|
+
ip,
|
|
122
|
+
port_,
|
|
123
|
+
username_,
|
|
124
|
+
password_,
|
|
125
|
+
use_ssl=True,
|
|
126
|
+
ca_certs="/path/ca.crt",
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
When the server enables Thrift mutual TLS, also configure a client certificate and an unencrypted PEM private key.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
session = Session(
|
|
134
|
+
ip,
|
|
135
|
+
port_,
|
|
136
|
+
username_,
|
|
137
|
+
password_,
|
|
138
|
+
use_ssl=True,
|
|
139
|
+
ca_certs="/path/ca.crt",
|
|
140
|
+
client_cert="/path/client.crt",
|
|
141
|
+
client_key="/path/client.key",
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`client_cert` and `client_key` must be set together. `client_key` should be protected by file permissions because encrypted private keys are not supported by this client API.
|
|
146
|
+
|
|
147
|
+
The same SSL parameters are available in `PoolConfig`, `TableSessionConfig`, `TableSessionPoolConfig`, and DBAPI `connect`.
|
|
148
|
+
|
|
115
149
|
### Data Definition Interface (DDL Interface)
|
|
116
150
|
|
|
117
151
|
#### DATABASE Management
|
|
@@ -628,5 +662,3 @@ Namely, these are
|
|
|
628
662
|
* Release to pypi
|
|
629
663
|
|
|
630
664
|
|
|
631
|
-
|
|
632
|
-
|
|
@@ -90,6 +90,40 @@ Notice: this RPC compression status of client must comply with that of IoTDB ser
|
|
|
90
90
|
session.close()
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### SSL and Mutual TLS
|
|
94
|
+
|
|
95
|
+
Use `use_ssl=True` and `ca_certs` to enable SSL and verify the server certificate.
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
session = Session(
|
|
99
|
+
ip,
|
|
100
|
+
port_,
|
|
101
|
+
username_,
|
|
102
|
+
password_,
|
|
103
|
+
use_ssl=True,
|
|
104
|
+
ca_certs="/path/ca.crt",
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
When the server enables Thrift mutual TLS, also configure a client certificate and an unencrypted PEM private key.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
session = Session(
|
|
112
|
+
ip,
|
|
113
|
+
port_,
|
|
114
|
+
username_,
|
|
115
|
+
password_,
|
|
116
|
+
use_ssl=True,
|
|
117
|
+
ca_certs="/path/ca.crt",
|
|
118
|
+
client_cert="/path/client.crt",
|
|
119
|
+
client_key="/path/client.key",
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`client_cert` and `client_key` must be set together. `client_key` should be protected by file permissions because encrypted private keys are not supported by this client API.
|
|
124
|
+
|
|
125
|
+
The same SSL parameters are available in `PoolConfig`, `TableSessionConfig`, `TableSessionPoolConfig`, and DBAPI `connect`.
|
|
126
|
+
|
|
93
127
|
### Data Definition Interface (DDL Interface)
|
|
94
128
|
|
|
95
129
|
#### DATABASE Management
|
|
@@ -606,5 +640,3 @@ Namely, these are
|
|
|
606
640
|
* Release to pypi
|
|
607
641
|
|
|
608
642
|
|
|
609
|
-
|
|
610
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apache-iotdb
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.12
|
|
4
4
|
Summary: Apache IoTDB client API
|
|
5
5
|
Author-email: Apache IoTDB <dev@iotdb.apache.org>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -112,6 +112,40 @@ Notice: this RPC compression status of client must comply with that of IoTDB ser
|
|
|
112
112
|
session.close()
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
### SSL and Mutual TLS
|
|
116
|
+
|
|
117
|
+
Use `use_ssl=True` and `ca_certs` to enable SSL and verify the server certificate.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
session = Session(
|
|
121
|
+
ip,
|
|
122
|
+
port_,
|
|
123
|
+
username_,
|
|
124
|
+
password_,
|
|
125
|
+
use_ssl=True,
|
|
126
|
+
ca_certs="/path/ca.crt",
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
When the server enables Thrift mutual TLS, also configure a client certificate and an unencrypted PEM private key.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
session = Session(
|
|
134
|
+
ip,
|
|
135
|
+
port_,
|
|
136
|
+
username_,
|
|
137
|
+
password_,
|
|
138
|
+
use_ssl=True,
|
|
139
|
+
ca_certs="/path/ca.crt",
|
|
140
|
+
client_cert="/path/client.crt",
|
|
141
|
+
client_key="/path/client.key",
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`client_cert` and `client_key` must be set together. `client_key` should be protected by file permissions because encrypted private keys are not supported by this client API.
|
|
146
|
+
|
|
147
|
+
The same SSL parameters are available in `PoolConfig`, `TableSessionConfig`, `TableSessionPoolConfig`, and DBAPI `connect`.
|
|
148
|
+
|
|
115
149
|
### Data Definition Interface (DDL Interface)
|
|
116
150
|
|
|
117
151
|
#### DATABASE Management
|
|
@@ -628,5 +662,3 @@ Namely, these are
|
|
|
628
662
|
* Release to pypi
|
|
629
663
|
|
|
630
664
|
|
|
631
|
-
|
|
632
|
-
|
|
@@ -57,6 +57,7 @@ iotdb/utils/IoTDBConstants.py
|
|
|
57
57
|
iotdb/utils/NumpyTablet.py
|
|
58
58
|
iotdb/utils/RowRecord.py
|
|
59
59
|
iotdb/utils/SessionDataSet.py
|
|
60
|
+
iotdb/utils/SessionUtils.py
|
|
60
61
|
iotdb/utils/Tablet.py
|
|
61
62
|
iotdb/utils/__init__.py
|
|
62
63
|
iotdb/utils/exception.py
|
|
@@ -85,4 +86,9 @@ tests/integration/dbapi/test_cursor.py
|
|
|
85
86
|
tests/integration/sqlalchemy/__init__.py
|
|
86
87
|
tests/integration/sqlalchemy/test_dialect.py
|
|
87
88
|
tests/unit/__init__.py
|
|
88
|
-
tests/unit/test_numpy_tablet.py
|
|
89
|
+
tests/unit/test_numpy_tablet.py
|
|
90
|
+
tests/unit/test_rpc_utils.py
|
|
91
|
+
tests/unit/test_session_connection.py
|
|
92
|
+
tests/unit/test_session_node_url.py
|
|
93
|
+
tests/unit/test_session_ssl.py
|
|
94
|
+
tests/unit/test_session_utils.py
|
|
@@ -16,48 +16,51 @@
|
|
|
16
16
|
# under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
+
import ipaddress
|
|
19
20
|
import logging
|
|
20
21
|
import random
|
|
21
|
-
import sys
|
|
22
22
|
import struct
|
|
23
|
+
import sys
|
|
23
24
|
import warnings
|
|
25
|
+
|
|
26
|
+
from iotdb.utils.SessionDataSet import SessionDataSet
|
|
27
|
+
from iotdb.utils.SessionUtils import filter_null_columns
|
|
24
28
|
from thrift.protocol import TBinaryProtocol, TCompactProtocol
|
|
25
29
|
from thrift.transport import TSocket, TTransport
|
|
26
30
|
from tzlocal import get_localzone_name
|
|
27
31
|
|
|
28
|
-
from iotdb.utils.SessionDataSet import SessionDataSet
|
|
29
32
|
from .template.Template import Template
|
|
30
33
|
from .template.TemplateQueryType import TemplateQueryType
|
|
31
34
|
from .thrift.common.ttypes import TEndPoint
|
|
32
35
|
from .thrift.rpc.IClientRPCService import (
|
|
33
36
|
Client,
|
|
34
|
-
|
|
37
|
+
TSAppendSchemaTemplateReq,
|
|
38
|
+
TSCloseSessionReq,
|
|
35
39
|
TSCreateAlignedTimeseriesReq,
|
|
40
|
+
TSCreateMultiTimeseriesReq,
|
|
41
|
+
TSCreateSchemaTemplateReq,
|
|
42
|
+
TSCreateTimeseriesReq,
|
|
43
|
+
TSDropSchemaTemplateReq,
|
|
44
|
+
TSExecuteStatementReq,
|
|
36
45
|
TSInsertRecordReq,
|
|
46
|
+
TSInsertRecordsOfOneDeviceReq,
|
|
47
|
+
TSInsertRecordsReq,
|
|
37
48
|
TSInsertStringRecordReq,
|
|
38
49
|
TSInsertTabletReq,
|
|
39
|
-
TSExecuteStatementReq,
|
|
40
|
-
TSOpenSessionReq,
|
|
41
|
-
TSCreateMultiTimeseriesReq,
|
|
42
|
-
TSCloseSessionReq,
|
|
43
50
|
TSInsertTabletsReq,
|
|
44
|
-
|
|
45
|
-
TSInsertRecordsOfOneDeviceReq,
|
|
46
|
-
TSCreateSchemaTemplateReq,
|
|
47
|
-
TSDropSchemaTemplateReq,
|
|
48
|
-
TSAppendSchemaTemplateReq,
|
|
51
|
+
TSOpenSessionReq,
|
|
49
52
|
TSPruneSchemaTemplateReq,
|
|
53
|
+
TSQueryTemplateReq,
|
|
50
54
|
TSSetSchemaTemplateReq,
|
|
51
55
|
TSUnsetSchemaTemplateReq,
|
|
52
|
-
TSQueryTemplateReq,
|
|
53
56
|
)
|
|
54
57
|
from .thrift.rpc.ttypes import (
|
|
55
58
|
TSDeleteDataReq,
|
|
59
|
+
TSInsertStringRecordsOfOneDeviceReq,
|
|
60
|
+
TSLastDataQueryReq,
|
|
56
61
|
TSProtocolVersion,
|
|
57
|
-
TSSetTimeZoneReq,
|
|
58
62
|
TSRawDataQueryReq,
|
|
59
|
-
|
|
60
|
-
TSInsertStringRecordsOfOneDeviceReq,
|
|
63
|
+
TSSetTimeZoneReq,
|
|
61
64
|
)
|
|
62
65
|
from .tsfile.utils.date_utils import parse_date_to_int
|
|
63
66
|
from .utils import rpc_utils
|
|
@@ -67,6 +70,48 @@ logger = logging.getLogger("IoTDB")
|
|
|
67
70
|
warnings.simplefilter("always", DeprecationWarning)
|
|
68
71
|
|
|
69
72
|
|
|
73
|
+
def _parse_endpoint_url(endpoint_url):
|
|
74
|
+
if endpoint_url.startswith("["):
|
|
75
|
+
end_index = endpoint_url.find("]")
|
|
76
|
+
if end_index <= 1 or end_index + 1 >= len(endpoint_url):
|
|
77
|
+
raise RuntimeError("invalid node url: {}".format(endpoint_url))
|
|
78
|
+
if endpoint_url[end_index + 1] != ":":
|
|
79
|
+
raise RuntimeError("invalid node url: {}".format(endpoint_url))
|
|
80
|
+
return endpoint_url[1:end_index], _parse_endpoint_port(
|
|
81
|
+
endpoint_url, endpoint_url[end_index + 2 :]
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
if "[" in endpoint_url or "]" in endpoint_url:
|
|
85
|
+
raise RuntimeError("invalid node url: {}".format(endpoint_url))
|
|
86
|
+
split = endpoint_url.rsplit(":", 1)
|
|
87
|
+
if len(split) != 2:
|
|
88
|
+
raise RuntimeError("invalid node url: {}".format(endpoint_url))
|
|
89
|
+
return split[0], _parse_endpoint_port(endpoint_url, split[1])
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _parse_endpoint_port(endpoint_url, port):
|
|
93
|
+
try:
|
|
94
|
+
return int(port)
|
|
95
|
+
except ValueError as e:
|
|
96
|
+
raise RuntimeError("invalid node url: {}".format(endpoint_url)) from e
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _is_wildcard_address(host):
|
|
100
|
+
if host is None:
|
|
101
|
+
return False
|
|
102
|
+
normalized_host = host
|
|
103
|
+
if normalized_host.startswith("[") and normalized_host.endswith("]"):
|
|
104
|
+
normalized_host = normalized_host[1:-1]
|
|
105
|
+
if normalized_host == "0.0.0.0":
|
|
106
|
+
return True
|
|
107
|
+
if ":" not in normalized_host:
|
|
108
|
+
return False
|
|
109
|
+
try:
|
|
110
|
+
return ipaddress.ip_address(normalized_host).is_unspecified
|
|
111
|
+
except ValueError:
|
|
112
|
+
return False
|
|
113
|
+
|
|
114
|
+
|
|
70
115
|
class Session(object):
|
|
71
116
|
DEFAULT_FETCH_SIZE = 5000
|
|
72
117
|
DEFAULT_USER = "root"
|
|
@@ -87,6 +132,8 @@ class Session(object):
|
|
|
87
132
|
use_ssl=False,
|
|
88
133
|
ca_certs=None,
|
|
89
134
|
connection_timeout_in_ms=None,
|
|
135
|
+
client_cert=None,
|
|
136
|
+
client_key=None,
|
|
90
137
|
):
|
|
91
138
|
self.__host = host
|
|
92
139
|
self.__port = port
|
|
@@ -117,6 +164,8 @@ class Session(object):
|
|
|
117
164
|
self.database = None
|
|
118
165
|
self.__use_ssl = use_ssl
|
|
119
166
|
self.__ca_certs = ca_certs
|
|
167
|
+
self.__client_cert = client_cert
|
|
168
|
+
self.__client_key = client_key
|
|
120
169
|
self.__connection_timeout_in_ms = connection_timeout_in_ms
|
|
121
170
|
self.__time_precision = "ms"
|
|
122
171
|
|
|
@@ -132,6 +181,8 @@ class Session(object):
|
|
|
132
181
|
use_ssl=False,
|
|
133
182
|
ca_certs=None,
|
|
134
183
|
connection_timeout_in_ms=None,
|
|
184
|
+
client_cert=None,
|
|
185
|
+
client_key=None,
|
|
135
186
|
):
|
|
136
187
|
if node_urls is None:
|
|
137
188
|
raise RuntimeError("node urls is empty")
|
|
@@ -145,14 +196,16 @@ class Session(object):
|
|
|
145
196
|
enable_redirection,
|
|
146
197
|
use_ssl=use_ssl,
|
|
147
198
|
ca_certs=ca_certs,
|
|
199
|
+
client_cert=client_cert,
|
|
200
|
+
client_key=client_key,
|
|
148
201
|
connection_timeout_in_ms=connection_timeout_in_ms,
|
|
149
202
|
)
|
|
150
203
|
session.__hosts = []
|
|
151
204
|
session.__ports = []
|
|
152
205
|
for node_url in node_urls:
|
|
153
|
-
|
|
154
|
-
session.__hosts.append(
|
|
155
|
-
session.__ports.append(
|
|
206
|
+
host, port = _parse_endpoint_url(node_url)
|
|
207
|
+
session.__hosts.append(host)
|
|
208
|
+
session.__ports.append(port)
|
|
156
209
|
session.__host = session.__hosts[0]
|
|
157
210
|
session.__port = session.__ports[0]
|
|
158
211
|
session.__default_endpoint = TEndPoint(session.__host, session.__port)
|
|
@@ -171,7 +224,7 @@ class Session(object):
|
|
|
171
224
|
self.__default_connection = self.init_connection(
|
|
172
225
|
self.__default_endpoint
|
|
173
226
|
)
|
|
174
|
-
except
|
|
227
|
+
except IoTDBConnectionException as e:
|
|
175
228
|
if not self.reconnect():
|
|
176
229
|
if str(e).startswith("Could not connect to any of"):
|
|
177
230
|
error_msg = (
|
|
@@ -232,9 +285,12 @@ class Session(object):
|
|
|
232
285
|
session_id = open_resp.sessionId
|
|
233
286
|
statement_id = client.requestStatementId(session_id)
|
|
234
287
|
|
|
235
|
-
except
|
|
288
|
+
except TTransport.TTransportException as e:
|
|
236
289
|
transport.close()
|
|
237
290
|
raise IoTDBConnectionException(e) from None
|
|
291
|
+
except Exception:
|
|
292
|
+
transport.close()
|
|
293
|
+
raise
|
|
238
294
|
|
|
239
295
|
if self.__zone_id is not None:
|
|
240
296
|
request = TSSetTimeZoneReq(session_id, self.__zone_id)
|
|
@@ -251,6 +307,7 @@ class Session(object):
|
|
|
251
307
|
def __get_transport(self, endpoint):
|
|
252
308
|
if self.__use_ssl:
|
|
253
309
|
import ssl
|
|
310
|
+
|
|
254
311
|
from thrift.transport import TSSLSocket
|
|
255
312
|
|
|
256
313
|
if sys.version_info >= (3, 10):
|
|
@@ -259,7 +316,21 @@ class Session(object):
|
|
|
259
316
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
|
260
317
|
context.verify_mode = ssl.CERT_REQUIRED
|
|
261
318
|
context.check_hostname = True
|
|
262
|
-
|
|
319
|
+
context.load_default_certs(ssl.Purpose.SERVER_AUTH)
|
|
320
|
+
if self.__has_text(self.__ca_certs):
|
|
321
|
+
context.load_verify_locations(cafile=self.__ca_certs)
|
|
322
|
+
if self.__has_text(self.__client_cert) or self.__has_text(
|
|
323
|
+
self.__client_key
|
|
324
|
+
):
|
|
325
|
+
if not self.__has_text(self.__client_cert) or not self.__has_text(
|
|
326
|
+
self.__client_key
|
|
327
|
+
):
|
|
328
|
+
raise TTransport.TTransportException(
|
|
329
|
+
message="client_cert and client_key must be set together."
|
|
330
|
+
)
|
|
331
|
+
context.load_cert_chain(
|
|
332
|
+
certfile=self.__client_cert, keyfile=self.__client_key
|
|
333
|
+
)
|
|
263
334
|
socket = TSSLSocket.TSSLSocket(
|
|
264
335
|
host=endpoint.ip, port=endpoint.port, ssl_context=context
|
|
265
336
|
)
|
|
@@ -275,6 +346,10 @@ class Session(object):
|
|
|
275
346
|
raise IoTDBConnectionException(e) from None
|
|
276
347
|
return transport
|
|
277
348
|
|
|
349
|
+
@staticmethod
|
|
350
|
+
def __has_text(value):
|
|
351
|
+
return value is not None and str(value).strip() != ""
|
|
352
|
+
|
|
278
353
|
def is_open(self):
|
|
279
354
|
return not self.__is_close
|
|
280
355
|
|
|
@@ -1021,6 +1096,8 @@ class Session(object):
|
|
|
1021
1096
|
:param tablet: a tablet specified above
|
|
1022
1097
|
"""
|
|
1023
1098
|
request = self.gen_insert_tablet_req(tablet)
|
|
1099
|
+
if request is None:
|
|
1100
|
+
return
|
|
1024
1101
|
try:
|
|
1025
1102
|
connection = self.get_connection(tablet.get_insert_target_name())
|
|
1026
1103
|
request.sessionId = connection.session_id
|
|
@@ -1049,19 +1126,24 @@ class Session(object):
|
|
|
1049
1126
|
if self.__enable_redirection:
|
|
1050
1127
|
request_group = {}
|
|
1051
1128
|
for i in range(len(tablet_lst)):
|
|
1052
|
-
|
|
1129
|
+
filtered = filter_null_columns(tablet_lst[i])
|
|
1130
|
+
if filtered is None:
|
|
1131
|
+
continue
|
|
1132
|
+
connection = self.get_connection(filtered.get_insert_target_name())
|
|
1053
1133
|
request = request_group.setdefault(
|
|
1054
1134
|
connection.client,
|
|
1055
1135
|
TSInsertTabletsReq(
|
|
1056
1136
|
connection.session_id, [], [], [], [], [], [], False
|
|
1057
1137
|
),
|
|
1058
1138
|
)
|
|
1059
|
-
request.prefixPaths.append(
|
|
1060
|
-
request.timestampsList.append(
|
|
1061
|
-
request.measurementsList.append(
|
|
1062
|
-
request.valuesList.append(
|
|
1063
|
-
request.sizeList.append(
|
|
1064
|
-
request.typesList.append(
|
|
1139
|
+
request.prefixPaths.append(filtered.get_insert_target_name())
|
|
1140
|
+
request.timestampsList.append(filtered.get_binary_timestamps())
|
|
1141
|
+
request.measurementsList.append(filtered.get_measurements())
|
|
1142
|
+
request.valuesList.append(filtered.get_binary_values())
|
|
1143
|
+
request.sizeList.append(filtered.get_row_number())
|
|
1144
|
+
request.typesList.append(filtered.get_data_types())
|
|
1145
|
+
if not request_group:
|
|
1146
|
+
return 0
|
|
1065
1147
|
for client, request in request_group.items():
|
|
1066
1148
|
try:
|
|
1067
1149
|
rpc_utils.verify_success_with_redirection_for_multi_devices(
|
|
@@ -1087,6 +1169,8 @@ class Session(object):
|
|
|
1087
1169
|
return 0
|
|
1088
1170
|
else:
|
|
1089
1171
|
request = self.gen_insert_tablets_req(tablet_lst)
|
|
1172
|
+
if request is None:
|
|
1173
|
+
return 0
|
|
1090
1174
|
try:
|
|
1091
1175
|
return rpc_utils.verify_success(self.__client.insertTablets(request))
|
|
1092
1176
|
except TTransport.TException as e:
|
|
@@ -1116,6 +1200,8 @@ class Session(object):
|
|
|
1116
1200
|
:param tablet: a tablet specified above
|
|
1117
1201
|
"""
|
|
1118
1202
|
request = self.gen_insert_tablet_req(tablet, True)
|
|
1203
|
+
if request is None:
|
|
1204
|
+
return
|
|
1119
1205
|
try:
|
|
1120
1206
|
connection = self.get_connection(tablet.get_insert_target_name())
|
|
1121
1207
|
request.sessionId = connection.session_id
|
|
@@ -1144,19 +1230,24 @@ class Session(object):
|
|
|
1144
1230
|
if self.__enable_redirection:
|
|
1145
1231
|
request_group = {}
|
|
1146
1232
|
for i in range(len(tablet_lst)):
|
|
1147
|
-
|
|
1233
|
+
filtered = filter_null_columns(tablet_lst[i])
|
|
1234
|
+
if filtered is None:
|
|
1235
|
+
continue
|
|
1236
|
+
connection = self.get_connection(filtered.get_insert_target_name())
|
|
1148
1237
|
request = request_group.setdefault(
|
|
1149
1238
|
connection.client,
|
|
1150
1239
|
TSInsertTabletsReq(
|
|
1151
1240
|
connection.session_id, [], [], [], [], [], [], True
|
|
1152
1241
|
),
|
|
1153
1242
|
)
|
|
1154
|
-
request.prefixPaths.append(
|
|
1155
|
-
request.timestampsList.append(
|
|
1156
|
-
request.measurementsList.append(
|
|
1157
|
-
request.valuesList.append(
|
|
1158
|
-
request.sizeList.append(
|
|
1159
|
-
request.typesList.append(
|
|
1243
|
+
request.prefixPaths.append(filtered.get_insert_target_name())
|
|
1244
|
+
request.timestampsList.append(filtered.get_binary_timestamps())
|
|
1245
|
+
request.measurementsList.append(filtered.get_measurements())
|
|
1246
|
+
request.valuesList.append(filtered.get_binary_values())
|
|
1247
|
+
request.sizeList.append(filtered.get_row_number())
|
|
1248
|
+
request.typesList.append(filtered.get_data_types())
|
|
1249
|
+
if not request_group:
|
|
1250
|
+
return 0
|
|
1160
1251
|
for client, request in request_group.items():
|
|
1161
1252
|
try:
|
|
1162
1253
|
rpc_utils.verify_success_with_redirection_for_multi_devices(
|
|
@@ -1182,6 +1273,8 @@ class Session(object):
|
|
|
1182
1273
|
return 0
|
|
1183
1274
|
else:
|
|
1184
1275
|
request = self.gen_insert_tablets_req(tablet_lst, True)
|
|
1276
|
+
if request is None:
|
|
1277
|
+
return 0
|
|
1185
1278
|
try:
|
|
1186
1279
|
return rpc_utils.verify_success(self.__client.insertTablets(request))
|
|
1187
1280
|
except TTransport.TException as e:
|
|
@@ -1208,6 +1301,8 @@ class Session(object):
|
|
|
1208
1301
|
:param tablet: a tablet specified above
|
|
1209
1302
|
"""
|
|
1210
1303
|
request = self.gen_insert_relational_tablet_req(tablet)
|
|
1304
|
+
if request is None:
|
|
1305
|
+
return
|
|
1211
1306
|
try:
|
|
1212
1307
|
connection = self.get_connection(tablet.get_insert_target_name())
|
|
1213
1308
|
request.sessionId = connection.session_id
|
|
@@ -1406,6 +1501,8 @@ class Session(object):
|
|
|
1406
1501
|
:param tablet: a tablet of data
|
|
1407
1502
|
"""
|
|
1408
1503
|
request = self.gen_insert_tablet_req(tablet)
|
|
1504
|
+
if request is None:
|
|
1505
|
+
return
|
|
1409
1506
|
try:
|
|
1410
1507
|
return rpc_utils.verify_success(self.__client.testInsertTablet(request))
|
|
1411
1508
|
except TTransport.TException as e:
|
|
@@ -1427,6 +1524,8 @@ class Session(object):
|
|
|
1427
1524
|
:param tablet_list: List of tablets
|
|
1428
1525
|
"""
|
|
1429
1526
|
request = self.gen_insert_tablets_req(tablet_list)
|
|
1527
|
+
if request is None:
|
|
1528
|
+
return
|
|
1430
1529
|
try:
|
|
1431
1530
|
return rpc_utils.verify_success(self.__client.testInsertTablets(request))
|
|
1432
1531
|
except TTransport.TException as e:
|
|
@@ -1442,29 +1541,35 @@ class Session(object):
|
|
|
1442
1541
|
raise IoTDBConnectionException(self.connection_error_msg()) from None
|
|
1443
1542
|
|
|
1444
1543
|
def gen_insert_tablet_req(self, tablet, is_aligned=False):
|
|
1544
|
+
filtered = filter_null_columns(tablet)
|
|
1545
|
+
if filtered is None:
|
|
1546
|
+
return None
|
|
1445
1547
|
return TSInsertTabletReq(
|
|
1446
1548
|
self.__session_id,
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1549
|
+
filtered.get_insert_target_name(),
|
|
1550
|
+
filtered.get_measurements(),
|
|
1551
|
+
filtered.get_binary_values(),
|
|
1552
|
+
filtered.get_binary_timestamps(),
|
|
1553
|
+
filtered.get_data_types(),
|
|
1554
|
+
filtered.get_row_number(),
|
|
1453
1555
|
is_aligned,
|
|
1454
1556
|
)
|
|
1455
1557
|
|
|
1456
1558
|
def gen_insert_relational_tablet_req(self, tablet, is_aligned=False):
|
|
1559
|
+
filtered = filter_null_columns(tablet)
|
|
1560
|
+
if filtered is None:
|
|
1561
|
+
return None
|
|
1457
1562
|
return TSInsertTabletReq(
|
|
1458
1563
|
self.__session_id,
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1564
|
+
filtered.get_insert_target_name(),
|
|
1565
|
+
filtered.get_measurements(),
|
|
1566
|
+
filtered.get_binary_values(),
|
|
1567
|
+
filtered.get_binary_timestamps(),
|
|
1568
|
+
filtered.get_data_types(),
|
|
1569
|
+
filtered.get_row_number(),
|
|
1465
1570
|
is_aligned,
|
|
1466
1571
|
True,
|
|
1467
|
-
|
|
1572
|
+
filtered.get_column_categories(),
|
|
1468
1573
|
)
|
|
1469
1574
|
|
|
1470
1575
|
def gen_insert_tablets_req(self, tablet_lst, is_aligned=False):
|
|
@@ -1475,12 +1580,17 @@ class Session(object):
|
|
|
1475
1580
|
type_lst = []
|
|
1476
1581
|
size_lst = []
|
|
1477
1582
|
for tablet in tablet_lst:
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1583
|
+
filtered = filter_null_columns(tablet)
|
|
1584
|
+
if filtered is None:
|
|
1585
|
+
continue
|
|
1586
|
+
device_id_lst.append(filtered.get_insert_target_name())
|
|
1587
|
+
measurements_lst.append(filtered.get_measurements())
|
|
1588
|
+
values_lst.append(filtered.get_binary_values())
|
|
1589
|
+
timestamps_lst.append(filtered.get_binary_timestamps())
|
|
1590
|
+
type_lst.append(filtered.get_data_types())
|
|
1591
|
+
size_lst.append(filtered.get_row_number())
|
|
1592
|
+
if not device_id_lst:
|
|
1593
|
+
return None
|
|
1484
1594
|
return TSInsertTabletsReq(
|
|
1485
1595
|
self.__session_id,
|
|
1486
1596
|
device_id_lst,
|
|
@@ -1960,7 +2070,7 @@ class Session(object):
|
|
|
1960
2070
|
|
|
1961
2071
|
def handle_redirection(self, device_id, endpoint: TEndPoint):
|
|
1962
2072
|
if self.__enable_redirection:
|
|
1963
|
-
if endpoint.ip
|
|
2073
|
+
if _is_wildcard_address(endpoint.ip):
|
|
1964
2074
|
return 0
|
|
1965
2075
|
if (
|
|
1966
2076
|
device_id not in self.__device_id_to_endpoint
|
|
@@ -49,6 +49,8 @@ class PoolConfig(object):
|
|
|
49
49
|
use_ssl: bool = False,
|
|
50
50
|
ca_certs: str = None,
|
|
51
51
|
connection_timeout_in_ms: int = None,
|
|
52
|
+
client_cert: str = None,
|
|
53
|
+
client_key: str = None,
|
|
52
54
|
):
|
|
53
55
|
self.host = host
|
|
54
56
|
self.port = port
|
|
@@ -68,6 +70,8 @@ class PoolConfig(object):
|
|
|
68
70
|
self.enable_redirection = enable_redirection
|
|
69
71
|
self.use_ssl = use_ssl
|
|
70
72
|
self.ca_certs = ca_certs
|
|
73
|
+
self.client_cert = client_cert
|
|
74
|
+
self.client_key = client_key
|
|
71
75
|
self.connection_timeout_in_ms = connection_timeout_in_ms
|
|
72
76
|
|
|
73
77
|
|
|
@@ -96,6 +100,8 @@ class SessionPool(object):
|
|
|
96
100
|
enable_redirection=self.__pool_config.enable_redirection,
|
|
97
101
|
use_ssl=self.__pool_config.use_ssl,
|
|
98
102
|
ca_certs=self.__pool_config.ca_certs,
|
|
103
|
+
client_cert=self.__pool_config.client_cert,
|
|
104
|
+
client_key=self.__pool_config.client_key,
|
|
99
105
|
connection_timeout_in_ms=self.__pool_config.connection_timeout_in_ms,
|
|
100
106
|
)
|
|
101
107
|
session.sql_dialect = self.sql_dialect
|
|
@@ -112,6 +118,8 @@ class SessionPool(object):
|
|
|
112
118
|
enable_redirection=self.__pool_config.enable_redirection,
|
|
113
119
|
use_ssl=self.__pool_config.use_ssl,
|
|
114
120
|
ca_certs=self.__pool_config.ca_certs,
|
|
121
|
+
client_cert=self.__pool_config.client_cert,
|
|
122
|
+
client_key=self.__pool_config.client_key,
|
|
115
123
|
connection_timeout_in_ms=self.__pool_config.connection_timeout_in_ms,
|
|
116
124
|
)
|
|
117
125
|
session.sql_dialect = self.sql_dialect
|
|
@@ -37,12 +37,29 @@ class Connection(object):
|
|
|
37
37
|
zone_id=Session.DEFAULT_ZONE_ID,
|
|
38
38
|
enable_rpc_compression=False,
|
|
39
39
|
sqlalchemy_mode=False,
|
|
40
|
+
use_ssl=False,
|
|
41
|
+
ca_certs=None,
|
|
42
|
+
connection_timeout_in_ms=None,
|
|
43
|
+
client_cert=None,
|
|
44
|
+
client_key=None,
|
|
40
45
|
):
|
|
41
|
-
self.__session = Session(
|
|
46
|
+
self.__session = Session(
|
|
47
|
+
host,
|
|
48
|
+
port,
|
|
49
|
+
username,
|
|
50
|
+
password,
|
|
51
|
+
fetch_size,
|
|
52
|
+
zone_id,
|
|
53
|
+
use_ssl=self.__to_bool(use_ssl),
|
|
54
|
+
ca_certs=ca_certs,
|
|
55
|
+
connection_timeout_in_ms=self.__to_optional_int(connection_timeout_in_ms),
|
|
56
|
+
client_cert=client_cert,
|
|
57
|
+
client_key=client_key,
|
|
58
|
+
)
|
|
42
59
|
self.__sqlalchemy_mode = sqlalchemy_mode
|
|
43
60
|
self.__is_close = True
|
|
44
61
|
try:
|
|
45
|
-
self.__session.open(enable_rpc_compression)
|
|
62
|
+
self.__session.open(self.__to_bool(enable_rpc_compression))
|
|
46
63
|
self.__is_close = False
|
|
47
64
|
except Exception as e:
|
|
48
65
|
raise ConnectionError(e)
|
|
@@ -89,3 +106,17 @@ class Connection(object):
|
|
|
89
106
|
|
|
90
107
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
91
108
|
self.close()
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def __to_bool(value):
|
|
112
|
+
if isinstance(value, bool):
|
|
113
|
+
return value
|
|
114
|
+
if isinstance(value, str):
|
|
115
|
+
return value.strip().lower() in ("true", "1", "yes", "y")
|
|
116
|
+
return bool(value)
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def __to_optional_int(value):
|
|
120
|
+
if value is None or value == "":
|
|
121
|
+
return None
|
|
122
|
+
return int(value)
|