Details
-
Epic
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
Python DB API Driver 3.0
-
Docs Required, Release Notes Required
Description
Requirements
- The implementation of the Python DB API or the Driver should be implemented using Python 3;
- The Driver should comply with Python DB-API 2.0: https://peps.python.org/pep-0249/;
- Performance of the Driver should be similar to the performance of other clients and drivers, e.g. JDBC;
- The first implementation should be as simple as possible, but it should be functional and allow for improvements in future;
- Preferably the Driver should be designed in such a way that makes it possible in the future to extend Driver’s API and turn it into a full-fledged Python Client.
Code Reuse
It is proposed to re-use the protocol part, which is currently used by ODBC and JDBC drivers. Its functionality should be more than enough for implementation of the Driver, as the DB API is much simpler than both JDBC and ODBC.
It is also proposed to re-use C++ code for data packing-unpacking (protocol messages, binary tuples).
It’s important to point out that in most of the implementations of such drivers, C/C++ code is duplicated in Python, but the first implementation of our Driver won’t include duplication of C++ code for the sake of simplicity. This means, if the user won’t be able to compile our C++ code on their platform for any reason, they won’t be able to use our Driver.
Type Mapping
The implementation of the specification is pretty straightforward and there is no need to discuss implementation of methods in detail. The only part that should probably be discussed is a data type mapping.
The following type mapping is suggested for the Driver:
Ignite Type | DB API Type | Python Type |
---|---|---|
NIL | None | None |
BOOLEAN | NUMBER | bool |
INT8 | NUMBER | int |
INT16 | NUMBER | int |
INT32 | NUMBER | int |
INT64 | NUMBER | int |
FLOAT | NUMBER | float |
DOUBLE | NUMBER | float |
DECIMAL | NUMBER | decimal.Decimal |
DATE | DATETIME | datetime.date |
TIME | DATETIME | datetime.time |
DATETIME | DATETIME | datetime.datetime |
TIMESTAMP | NUMBER | Timestamp(float) |
UUID | STRING | uuid.UUID |
STRING | STRING | str |
BYTE_ARRAY | BINARY | bytes |
PERIOD | DATETIME | ??? |
DURATION | DATETIME | datetime.timedelta |