[英]Querying datetime.datetime on appengine acts different then dev server help!
I'm having some trouble with stuff that work locally and dont work on the app engine python environment: 我在本地工作的东西遇到了麻烦,无法在App Engine python环境中工作:
Basically, i want to get a program from an epg between ranges of date and time. 基本上,我想从日期和时间范围之间的epg获取程序。 i know i cannot do two where > < so i saw a suggestion to save the dates as list as datetime.datetime which i did.
我知道我不能在两个地方做> <所以我看到了一个建议,将日期另存为datetime.datetime。
[datetime.datetime(2010, 5, 10, 14, 25), datetime.datetime(2010, 5, 10, 15, 0)]
This is ok. 还行吧。 but when i try to compare to it:
但是当我尝试与之比较时:
progranon = get_object(Programs2Channel,
'channel_id =', channelobj.key(),
'endstartdate >', programstart_minex,
'endstartdate <', programstart_minex
)
This for some reason works locally, but fails to retrieve the data on the app engine. 由于某种原因,这可以在本地使用,但无法在应用引擎上检索数据。
*Im using Google app engine django patch which uses the get_object to retrieve data in transactions. *我使用的是Google app引擎django补丁,该补丁使用get_object检索交易中的数据。
Please help. 请帮忙。
Here are more details: 以下是更多详细信息:
this is the LIST: 这是清单:
[datetime.datetime(2010, 5, 13, 10, 45), datetime.datetime(2010, 5, 13, 11, 30)]
#this is the query:
programstart = ""+year+"-"+month+"-"+day+" "+hour+":"+minute
programstart_minex = datetime.strptime(programstart, "%Y-%m-%d %H:%M")
progranon = Programs2Channel.gql('WHERE channel_id = :channelid AND endstartdate > :programstartx AND endstartdate < :programstartx',channelid = channelobj.key(),programstartx=programstart_minex).get()
could this be the issue? 这可能是问题吗?
From: http://code.google.com/appengine/docs/python/datastore/gqlreference.html 来自: http : //code.google.com/appengine/docs/python/datastore/gqlreference.html
a datetime, date, or time literal, with either numeric values or a string representation, in the following forms: DATETIME(year, month, day, hour, minute, second) DATETIME('YYYY-MM-DD HH:MM:SS')
日期时间,日期或时间文字,具有数字值或字符串表示形式,格式如下:DATETIME(年,月,日,时,分,秒)DATETIME('YYYY-MM-DD HH:MM:SS ')
my local server dev saves the datetime as numerical YYYY-MM-DD while the app engine saves datetime.datetime(2010, 5, 10, 14, 25), 我的本地服务器开发人员将日期时间另存为数字YYYY-MM-DD,而应用程序引擎将日期时间另存为datetime.datetime(2010,5,10,14,25),
LOCAL datetime list: 本地日期时间列表:
2010-05-09 08:30:00,2010-05-09 09:00:00
APP ENGINE LIST: APP引擎列表:
[datetime.datetime(2010, 5, 13, 10, 45), datetime.datetime(2010, 5, 13, 11, 30)]
maybe this is the issue? 也许这是问题吗?
Unfortunately, this is a known issue with the dev_appserver and querying on lists. 不幸的是,这是dev_appserver和列表查询的已知问题。
However, the dev_appserver now includes an experimental sqlite stub, which doesn't have this issue. 但是,dev_appserver现在包含一个实验性sqlite存根,它没有此问题。 Try running it with --use_sqlite, and see if that helps - it should!
尝试使用--use_sqlite运行它,看看是否有帮助-应该!
How about querying just querying for programs that start after mindate (just the > query) and then filtering in memory? 如何查询仅查询介意后启动的程序(仅>查询)然后在内存中进行过滤? If its a TV Guide, we're not talking thousand of possible entities right?
如果是电视指南,我们不是在谈论数千个实体,对不对? probably ~100 tops?
大概100个上衣?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.