title: Sqlalchemy : Dynamically create table from Scrapy item
body: <p>I'm working with sqlalchemy 1.1 and scrapy. I'm currently using a a pipeline to store extracted data in a sqllite table via sqlalchemy . I'd like to dynamically create a table to accommodate the item being scraped.</p>
  
  <p>My static pipeline element looks like:</p>
  
  <pre><code>class SQLlitePipeline(object):
  
      def __init__(self):
          db_path = "sqlite:///"+settings.SETTINGS_PATH+"\\data.db"
          _engine = create_engine(db_path)
          _connection = _engine.connect()
          _metadata = MetaData()
          _stack_items = Table(table_name, _metadata,
                               Column("id", Integer, primary_key=True),
                               Column("value", Text))
                               Column("value2", Text))
          _metadata.create_all(_engine)
          self.connection = _connection
          self.stack_items = _stack_items
  
      def process_item(self, item, spider):
  
              try:
                  ins_query = self.stack_items.insert().values(
                  value=item['value'],
                  value2=item['value2'],)
                  self.connection.execute(ins_query)
              except IntegrityError:
                      print('THIS IS A DUP')
              return item
  </code></pre>
  
  <p>items.py:</p>
  
  <pre><code>class Filtered_Item(scrapy.Item):
  
      value= scrapy.Field()
      value2= scrapy.Field()
  </code></pre>
  
  <p>How can I modify the pipeline above to dynamically create and insert the filtered item's values instead of having these hard coded in like they are now?</p>