简体   繁体   中英

How to store data to datastore - AppEngine

I am new to Python & AppEngine.

I am trying to use Feedparser to cache a feed to a datastore.

My code is at http://pastebin.com/uWPdWUm2

For some reason it doesn't work - it does not add the data to the datastore.

Any ideas? I am stumped.

You just forgot to use parenthesis in your model declaration.

Your code:

class FeedEntry3(db.Model):
    title = db.StringProperty
    link = db.StringProperty
    content = db.TextProperty

What it should be:

class FeedEntry3(db.Model):
    title = db.StringProperty()
    link = db.StringProperty()
    content = db.TextProperty()

Are you sure you are getting the values correcty or at all from feed parser? Have you tried to log them. Also for purpose of discussion if you think x.put is not working then separate that out and test that only eg

x = FeedEntry3()
x.title = "test title"
x.link = "test link"
x.content = "test content"
x.put()

Have you tried that, does that work? if that works most probably you are not getting values from feedparser, debug and log that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM