如何将嵌套的dict插入Cassandra

时间:2016-03-01 06:58:38

标签: python database dictionary cassandra

您好我在Python词典中有Meetup数据,我正在尝试将其插入到Cassandra数据库中。我发现这个链接(Insert a dict in cassandra DB)显示了如何做到这一点,但字典是一个扁平的字典。你怎么能插入嵌套字典?我想让它非嵌套(从字典中挑选几个数据)

借用链接的示例,我不确定columns.在实际案例中的含义。

class CustomerEventsServiceEvent(Model):
    __table_name__ = "customer_events_service.events"

    acceptFirstContactDuration = columns.Decimal()
    allSeenPageCount = columns.Decimal()
    callAcceptedCount = columns.Decimal()

有人可以帮忙吗?

示例字典(我的dict中的许多事件中只有一个事件):

{u'description': u'<p>In this class, you will be guided through a series of yoga poses (asanas), which are intended to increase spatial awareness, balance, strength, and flexibility. </p>\n<p><b>Each week, a different blend of essential oils will be diffused through the studio. </b></p>\n<p><i><b>$11.00 for 1 hour of Aromatherapy Yoga</b></i> <br></p>\n<p>The class utilizes a variety of breathing techniques (pranayama), which are designed to regulate the heart rate and decrease mental tension. This is an alignment-focused class, typically beginning and ending with a restorative posture, followed by a flowing sequence of movements that coordinate with the breath (vinyasa).</p>',
 u'duration': 3600000,
 u'event_url': u'http://www.meetup.com/Denver-Holistic-Health-Spiritual-Meetup/events/229141613/',
 u'group': {u'category': {u'id': 14,
                          u'name': u'health/wellbeing',
                          u'shortname': u'health-wellbeing'},
            u'city': u'Englewood',
            u'country': u'us',
            u'group_lat': 39.65,
            u'group_lon': -104.98,
            u'id': 19558352,
            u'join_mode': u'open',
            u'name': u'Denver Holistic Health/ Spiritual Meetup',
            u'state': u'CO',
            u'urlname': u'Denver-Holistic-Health-Spiritual-Meetup'},
 u'id': u'229141613',
 u'maybe_rsvp_count': 0,
 u'mtime': 1456793890358,
 u'name': u'Aromatherapeutic Yoga',
 u'payment_required': u'0',
 u'rsvp_limit': 10,
 u'status': u'upcoming',
 u'time': 1456873200000,
 u'utc_offset': -25200000,
 u'venue': {u'address_1': u'3358 Larimer st., Denver, CO 80205',
            u'city': u'Denver',
            u'country': u'us',
            u'lat': 39.765701,
            u'lon': -104.975655,
            u'name': u'Integrative Health Denver',
            u'state': u'CO'},
 u'venue_visibility': u'public',
 u'visibility': u'public',
 u'yes_rsvp_count': 4}

0 个答案:

没有答案
相关问题