Skip to content

Python Driver: Handling datetime alternatives #4503

Open

Description

@brianjpetersen

There are a few alternative Python libraries for handling datetimes. For example, Delorean and Arrow make it much easier to work with timezone-aware objects. Unfortunately, these two don't subclass from datetime (for good reasons), so the AST doesn't know how to handle them. It'd be convenient if the RethinkDB driver could handle these without the client having to explicitly cast to datetime prior to persisting.

Activity

  1. mlucy commented on Jul 6, 2015

    @mlucy
    Member

    Thanks for the suggestion @brianjpetersen !

    One problem with this is what to return -- we only have one ReQL time type, so if someone inserted a time using one of these other types and then retrieved the row they'd get back the Python datetime type instead. Maybe we could solve that by having an optarg to run that specifies which Python type to give back for ReQL types?

    @Tryneus, any thoughts?

  2. brianjpetersen commented on Jul 6, 2015

    @brianjpetersen
    Author

    I hadn't thought of how to specify the return type, but perhaps the most general solution would allow the user to define an encoder and a decoder to perform arbitrary mappings prior to being parsed/returned by RethinkDB (this could probably stand alone in the client code, but I think it's a common enough recipe that you may want to provide first-class support similar to the encoder/decoder options in Python's JSON module).

  3. mglukhovsky commented on Jul 6, 2015

    @mglukhovsky
    Member

    I think this is worthwhile -- I couldn't imagine manipulating dates and times in Python without Delorean (and Arrow looks neat!)

  4. added this to the 2.2 milestone on Jul 6, 2015
  5. mlucy commented on Jul 6, 2015

    @mlucy
    Member

    Alright, putting this into 2.2 and marking as a ReQL proposal since we need to discuss the API for specifying what format to return times in. (Probably we'll just extend the time_format optarg.)

  6. deontologician commented on Jul 6, 2015

    @deontologician
    Contributor

    Related to #3506

  7. marshall007 commented on Jul 7, 2015

    @marshall007
    Contributor

    I typically use moment for date manipulation, so I'd like to see this in the JS driver as well.

    I think I'd prefer to override the serialization/deserialization functions for any pseudo type (similar to what @brianjpetersen suggested) rather than an optarg specific to datetimes.

  8. mlucy commented on Jul 7, 2015

    @mlucy
    Member

    There's already a time_format optarg that accepts native and raw, so it might be easiest to just extend that, but I'm not necessarily opposed to a more general system.

  9. shastingspod commented on Jul 7, 2015

    @shastingspod

    +1

  10. modified the milestones: 2.2-polish, 2.2 on Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions