我应该首先提到我正在通过 Flask-SqlAlchemy 使用 SqlAlchemy。我不相信这会影响问题,但如果确实如此,请告诉我。
这是我在 SqlAlchemy 中运行 create_all 函数时收到的错误消息的相关部分
InterfaceError: (InterfaceError) Error binding parameter 4 - probably unsupported type. u'INSERT INTO podcasts (feed_url, title, url, last_updated, feed_data) VALUES (?, ?, ?, ?, ?)' (u'http://example.com/feed', u'Podcast Show Title', u'http://example.com', '2012-04-17 20:28:49.117000'
这是我的模型:
class Podcast(db.Model):
import datetime
__tablename__ = 'podcasts'
id = db.Column(db.Integer, primary_key=True)
feed_url = db.Column(db.String(150), unique=True)
title = db.Column(db.String(200))
url = db.Column(db.String(150))
last_updated = db.Column(db.DateTime, default=datetime.datetime.now)
feed_data = db.Column(db.Text)
def __init__(self, feed_url):
import feedparser
self.feed_url = feed_url
self.feed_data = feedparser.parse(self.feed_url)
self.title = self.feed_data['feed']['title']
self.url = self.feed_data['feed']['link']
有人能告诉我如何让它工作吗?我也尝试过以下模型,但这也行不通。同样的错误。
class Podcast(db.Model):
import datetime
__tablename__ = 'podcasts'
id = db.Column(db.Integer, primary_key=True)
feed_url = db.Column(db.String(150), unique=True)
title = db.Column(db.String(200))
url = db.Column(db.String(150))
last_updated = db.Column(db.DateTime)
feed_data = db.Column(db.Text)
def __init__(self, feed_url):
import feedparser
self.feed_url = feed_url
self.feed_data = feedparser.parse(self.feed_url)
self.last_updated = datetime.datetime.now()
self.title = self.feed_data['feed']['title']
self.url = self.feed_data['feed']['link']