| Bug #103669 | Contribution: pendulum just perform the same as datetime in convert | ||
|---|---|---|---|
| Submitted: | 12 May 2021 14:02 | Modified: | 27 May 2021 14:26 |
| Reporter: | OCA Admin (OCA) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / Python | Severity: | S3 (Non-critical) |
| Version: | OS: | Any | |
| Assigned to: | CPU Architecture: | Any | |
[12 May 2021 14:02]
OCA Admin
[12 May 2021 14:02]
OCA Admin
Contribution submitted via Github - pendulum just perform the same as datetime in convert (*) Contribution by A S (Github crawlersick, mysql-connector-python/pull/69#issuecomment-839400546): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: git_patch_624155870.txt (text/plain), 2.28 KiB.
[12 May 2021 16:28]
MySQL Verification Team
Thank you for the contribution.
[27 May 2021 14:15]
Nuno Mariz
Posted by developer:
Connector/Python allows to add custom data types converters easily, by creating a subclass of mysql.connector.conversion.MySQLConverterBase. My advice is to subclass the existing mysql.connector.conversion.MySQLConverter and add your custom data types.
Then in the connection options you can pass your custom converter class:
from mysql.connector.conversion import MySQLConverter
class MyCustomConverter(MySQLConverter):
# Make the necessary changes
(...)
conn = mysql.connector.connect(
host="127.0.0.1",
port=3306,
user="myuser",
password="mypass",
converter_class=MyCustomConverter,
)
[27 May 2021 14:26]
Nuno Mariz
Posted by developer: Thanks for the contribution, but for custom converters we prefer the usage of the `converter_class` mechanism.
[6 Feb 2023 9:01]
MCCATHY John
thx for the update, it is really a better way to code instead of directly 'hack in source code'.
