赞
踩
本文通过 py2neo 来创建创建图数据库节点,节点分为四类:年、月、周和日,关系包含:年到月、月到周、周到日。
from py2neo import Graph from py2neo.ogm import GraphObject, Property, RelatedTo class Year(GraphObject): ''' 年节点 ''' __primarykey__ = 'year' year = Property() class Month(GraphObject): ''' 月节点 ''' __primarykey__ = 'month' month = Property() date_in = RelatedTo('Year', 'DATE_IN') class Week(GraphObject): ''' 周节点 ''' __primarykey__ = 'week' week = Property() date_in = RelatedTo('Month', 'DATE_IN') class Date(GraphObject): ''' 日节点 ''' __primarykey__ = 'date' date = Property() # 日期字符串 %Y%m%d timestamp = Property() # 时间戳 week = Pr
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。