-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return TIMESTAMP
types as timezone-aware native Python datetime
objects
#445
Conversation
TIMESTAMP
types as timezone-aware native Python datetime
objectsTIMESTAMP
types as timezone-aware native Python datetime
objects
c2c0bfc
to
b8bc5e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It looks good, I have some comments around docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear Marios,
I've added some commits and hopefully addressed your suggestions well. Please let me know about anything missing, or where the patch could be improved further.
With kind regards,
Andreas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thank you! Left a comment about a test method name.
349b92e
to
4c0fcb9
Compare
33ecbf3
to
4e88a10
Compare
TIMESTAMP
types as timezone-aware native Python datetime
objectsTIMESTAMP
types as timezone-aware native Python datetime
objects
f635078
to
3f79183
Compare
4c0fcb9
to
9ef9d61
Compare
TIMESTAMP
types as timezone-aware native Python datetime
objectsTIMESTAMP
types as timezone-aware native Python datetime
objects
135caf7
to
eba6f89
Compare
98630d0
to
48d8bd7
Compare
48d8bd7
to
77dc5df
Compare
This is additional API convenience based on the data type converter machinery. A `time_zone` keyword argument can be passed to both the `connect()` method, or when creating new `Cursor` objects. The `time_zone` attribute can also be changed at runtime on both the `connection` and `cursor` object instances. Examples: - connect('localhost:4200', time_zone=pytz.timezone("Australia/Sydney")) - connection.cursor(time_zone="+0530")
77dc5df
to
8d8a6d1
Compare
About
When requested, make the driver return timezone-aware native Python
datetime
objects for CrateDB'sTIMESTAMP
types. The user can easily supply the desired time zone by different means.Rationale
@mfussenegger asked at #442 (review):
I shared some initial thoughts about it at #442 (review) ff., and finally settled with this implementation, separately from the baseline implementation for the data type converter.
Details
This patch adds additional convenience based on the data type converter machinery added with #442.
time_zone
keyword argument can be passed to both theconnect()
method, or when creating newCursor
objects.time_zone
attribute can also be changed at runtime on both theconnection
andcursor
object instances.Different ways to populate the
time_zone
value are supported. Some examples::datetime.timezone.utc
datetime.timezone(datetime.timedelta(hours=7), name="MST")
pytz.timezone("Australia/Sydney")
zoneinfo.ZoneInfo("Australia/Sydney")
+0530
(UTC offset in string format)Acknowledgements
This interface was inspired by the DBAPI drivers for MySQL and Elasticsearch. Thanks.
Synopsis
Use
time_zone
argument when creating a new connection. Here, use apytz.timezone
object.Use
time_zone
argument when creating a new cursor. Here, use an UTC offset string.References
Cursor
object #442Backlog