scrapy-sqlitem
scrapy-sqlitem copied to clipboard
Items don't populate from models
trafficstars
I'm following your example code identically, and the Fields don't populate in these items. Here's some example code:
>>> from sqlalchemy.ext.declarative import declarative_base
>>> from sqlalchemy import Column, Integer, String
>>> Base = declarative_base()
>>> class MyModel(Base):
... __tablename__ = 'new_table'
... id = Column(Integer, primary_key=True)
... name = Column(String(32))
...
>>> class MyItem(SqlItem):
... sqlmodel = MyModel
...
>>> item = MyItem()
>>> item.fields
{}
>>> item['name'] = 'new_name'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../lib/python3.5/site-packages/scrapy/item.py", line 63, in __setitem__
(self.__class__.__name__, key))
KeyError: 'MyItem does not support field: name'
>>>
Is there something I'm missing here? It's basically the same implementation as django-item, which had no problem populating the necessary fields.
scrapy-sqlitem==0.1.2
Scrapy==1.1.2
SQLAlchemy==1.0.14
Same problem here.
Has the same issue. Assuming you were using Python 3, PR #2 should fix it