Python SqlAlchemy generate table classes pragmatically -


given list of table names, i'm trying generate sqlalchemy db table classes programmatically. here do:

def generate_table_class_list(engine):     base = declarative_base(engine)     table_names = ['table_a', 'table_b']     table_classes = dict()     table in table_names:         table_classes[table] = generate_table_class(table)     return table_classes  def generate_table_class(base, table_name):     return type(table_name, (base,), dict(__tablename__ = table_name,                                           __table_args__ = {'autoload' : true}))  

when run generate_table_class_list(engine), got following error messages:

/opt/packages/sqlalchemy/engine/result.pyc in first(self)     829         try:     830             if row not none:     --> 831                 return self.process_rows([row])[0]     832             else:     833                 return none  /opt/packages/sqlalchemy/engine/result.pyc in process_rows(self, rows)     759         else:     760             return [process_row(metadata, row, processors, keymap)     --> 761                     row in rows]     762      763     def fetchall(self):  typeerror: row must sequence 

i used similar scripts before same version sqlalchemy , works. however, doesn't work time.

any appreciated. in advance.

well after several days researching , testing, figure out. when create engine, set cursor class ssdictcursor. when swtiched sscursor, works fine me, though still don't why ssdictcursor breaks code.


Comments

Popular posts from this blog

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -

java - How to specify maven bin in eclipse maven plugin? -