我正在尝试使用Bulkloader从我的数据存储区下载数据,但DateTimeProperty的精度似乎没有了,除非我做错了。
这是我试图下载的数据的属性:
class LoggingPrimitive(polymodel.PolyModel):
[...]
start = ndb.DateTimeProperty(auto_now_add=True, required=True)
这是我的bulkloader.yaml文件
- kind: LoggingPrimitive
connector: csv
connector_options:
export_options:
delimiter: "|"
property_map:
[...]
- property: start
external_name: start
# Type: Date/Time Stats: 5123 properties of this type in this kind.
import_transform: transform.import_date_time('%Y-%m-%dT%H:%M:%S')
export_transform: transform.export_date_time('%Y-%m-%d %H:%M:%S.%f')
我下载的CSV中的数据如下所示:
2013-05-25 22:06:17.
因此,下载的CSV数据不包含毫秒数。
当我在交互式控制台中使用transform.export_date_time函数时,我确实得到了毫秒。
fn=transform.export_date_time('%Y-%m-%d %H:%M:%S.%f')
print fn(l.start)
因此毫秒信息在数据存储区中,但似乎在bulkload过程中丢失了。
任何线索?
答案 0 :(得分:1)
使用Python 2.7运行bulkloader解决了这个问题。
显然,我运行bulkloader的机器使用的是Python 2.5,它不支持%f宏,请参阅How can I parse a time string containing milliseconds in it with python?