- metadata.create_all()
-
- # SQLAlchemy is retarded and there is no way for me to get a list of ORM
- # classes besides to inspect the module they all happen to live in for
- # things that look right.
- table_base = tables.TableBase
- orm_classes = {} # table object => table class
-
- for name in dir(tables):
- # dir() returns strings! How /convenient/.
- thingy = getattr(tables, name)
-
- if not isinstance(thingy, type):
- # Not a class; bail
- continue
- elif not issubclass(thingy, table_base):
- # Not a declarative table; bail
- continue
- elif thingy == table_base:
- # Declarative table base, so not a real table; bail
- continue
-
- # thingy is definitely a table class! Hallelujah.
- orm_classes[thingy.__table__] = thingy
+ print_start('Creating tables')
+ for n, table in enumerate(table_objs):
+ table.create()
+ print_status('%s/%s' % (n, len(table_objs)))
+ print_done()
+ connection = session.connection()