title: SQLAlchemy create dynamic tables and columns
body: <p>I'm trying to create db tables and columns dynamically in line with the data I retrieve.
  I retrieve a list of databases, a list of column names and attributes such as column type, primary_key / unique, nullable as well as other metadate.
  I'm trying to use this information to create the tables dynamically and have been using the forum posts to get a better idea of how to achieve this. So I want to create the tables based on the information I retrieve - database and the column information (colnames and column type, primary key and nullable information. This information retrieved could change daily or weekly.
  Forum post #1 - <a href="https://stackoverflow.com/questions/42260976/sqlalchemy-dynamically-create-table-and-mapped-class">Sqlalchemy dynamically create table and mapped class</a></p>
  
  <pre><code>postgresql_db = engine(...)
  
  post_meta = sql.MetaData(bind=postgresql_db.engine)
  
  post_meta.reflect(schema='customers')
  
  connection = postgresql_db.engine.connect()
  
  col_names = ['id', 'fname', 'lname', 'age']
  ctype = ['Integer', 'String', 'String', 'Integer']
  pk = ['True', 'False', 'False', 'False']
  nulls = ['No', 'No', 'No', 'No']
  
  class test(object):
  
       test = Table('customers', post_meta,
                *(Column(col, ctype, primary_key=pk, nullable=nulls)
             for col, ctype, pk, nulls in zip(col_names, ctype, pk, nulls))
  
  test.create()
  </code></pre>
  
  <p>There is an error message: 
  <code>AttributeError: 'list' object has no attribute _set_parent_with_dispatch</code>
  Can't seem to identify what this error is referring to exactly.</p>
  
  <p>Traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/xxx/db.py", line 247, in &lt;module&gt;
      main()
    File "C:/Users/xxx/db.py", line 168, in main
      for col, ctype, pk, nulls in zip(col_names, ctype, pk, nulls)
    File "C:/Users/xxx/apidb.py", line 168, in &lt;genexpr&gt;
      for col, ctype, pk, nulls in zip(col_names, ctype, pk, nulls)
    File "C:\Python27\lib\site-packages\sqlalchemy\sql\schema.py", line 1234, in __init__
      self._init_items(*args)
    File "C:\Python27\lib\site-packages\sqlalchemy\sql\schema.py", line 79, in _init_items
      item._set_parent_with_dispatch(self)
  AttributeError: 'list' object has no attribute '_set_parent_with_dispatch'
  </code></pre>
  
  <p>Any ideas what I am doing wrong?</p>