Thanks, am using SQLite3. I think it's better to set everything to 
offset-naive too. I did so by doing this:

rss.py:

class RssFeed(Base):
        ...
        latestpost = Column(DateTime)

tasks.py:

                pub_time = parse(post.published)

*                pub_time_naive = pub_time.replace(tzinfo=None)*

And things seem to "take" just fine now.


On Saturday, August 2, 2014 10:33:43 PM UTC-4, Michael Bayer wrote:
>
>
> On Aug 2, 2014, at 5:00 PM, Michael <taoma...@gmail.com <javascript:>> 
> wrote:
>
> *TypeError: can't compare offset-naive and offset-aware datetimes*
>
>
> I'm comparing the date of the rss feed items published date with the 
> latestpost of the rss feed. I ensure that the dates generated have 
> pytz.UTC() added. Note the actual issue happens in line 61 of 
> fetch_rss_posts task. Here is the py source of the tasks:
>
> http://pastebin.com/FPNvHLp4
>
> note on line 61 I'm simply doing 
> feed.latestpost = utc_pub_time
>
>
> I generate latestpost in an alembic migration script, of which I'm sure 
> I'm adding offset information with pytz.UTC() here is how I generate the 
> RssFeed member, latest_post on line 32:
>
> http://pastebin.com/eN2kipVs
>
> Here is some logging:
>
> http://pastebin.com/Vb31bCP6
>
> Another interesting thing is, the issue doesn't actually occur until after 
> the rss feed completely parsed.
>
>
> I don’t see information here on what database backend this is but to my 
> knowledge only the postgresql backend has any ability at all to deal with 
> offset-aware datetime objects, and you’d need to ensure timezone=True on 
> the Python side and “TIMESTAMP WITH TIMEZONE” on the DB side.  Within the 
> flush here, using echo=‘debug’ will show what kinds of values are being 
> sent out as well as what kind are being returned from the Python DBAPI.     
> Typically the date times coming back as result sets don’t have timezone 
> information added.   I’m not sure what psycopg2’s behavior is here, you 
> might need a custom type object that adds the tz info appropriately.   (if 
> it were me, I’d enforce all offset-naive UTC datetimes everywhere).
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to