1
我的rethinkdb以以下格式存儲數據。如何使用python將字符串轉換爲rethinkdb中的日期?
data = [{
'appName': "app1",
'startTime': "Mon, 14 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 14 Feb 2017 05:15:00 GMT",
'status': "SUCCESS"
},
{
'appName': "app1",
'startTime': "Mon, 13 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 13 Feb 2017 05:15:00 GMT",
'status': "FAILED"
},
{
'appName': "app2",
'startTime': "Mon, 13 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 13 Feb 2017 05:15:00 GMT",
'status': "RUNNING"
}]
我需要獲取所有應用程序的最新信息。
r.table('apps').group('appName').max('startTime').run()
但是由於我的startTime被存儲爲一個字符串,我不能做一個最大操作。
我嘗試更新表中的值如下,
r.table('apps').update({'startTimeDate': pytz.timezone('Europe/Rome').localize(datetime.strptime(r.row['startTime'], '%a, %d %b %Y %H:%M:%S GMT'))}).run()
我收到一個錯誤:
TypeError: must be string, not Bracket
如何堅持startTime和結束時間的日期rethinkdb從字符串?