cassandra

Using Arrow with the DataStax Cassandra Driver

It seems fitting to talk about date time objects on leap day!

We use the awesome python package arrow in our codebase for convenient and developer friendly manipulation of datetime objects. Although arrow is datetime compatible, it was not immediately compatible with the DataStax Cassandra Driver out of the box.

Fortunately, the DataStax driver is open source! Of course, it’s useful to read and learn from, but it also helped me figure out the solution. Stepping through the driver’s code, I eventually stumbled upon this section of code:

This wonderful docstring even says that users can directly update the mapping to including their own datatypes. Since arrow is datetime compatible, we are able to add support for arrow objects with the following line of code:

That’s it! I hope that was useful for you. Our APIs are written in Python and we heavily leverage both Redis and Cassandra to support our mobile app, mCent. If you’re interested in full stack development, please contact us!

Discussion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pingbacks & Trackbacks

  1. Cassandra and Freezegun’s FakeDateTime | Jana Technology