scrapy-sqlitem icon indicating copy to clipboard operation
scrapy-sqlitem copied to clipboard

Items don't populate from models

Open chadlagore opened this issue 9 years ago • 2 comments
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

chadlagore avatar Aug 28 '16 21:08 chadlagore

Same problem here.

sils avatar Dec 09 '16 21:12 sils

Has the same issue. Assuming you were using Python 3, PR #2 should fix it

bpgoldsb avatar Apr 24 '17 02:04 bpgoldsb