RE: [sqlalchemy] Bulk creation of columns
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of pravin battula Sent: 21 September 2011 12:54 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Bulk creation of columns Hi, How can i create columns in bulk using create_column method? I tried as below,. migrate_engine = create_engine('mysql://root:root@localhost/ payroll', echo=False) metadata = MetaData(bind = migrate_engine) metadata.reflect(bind = migrate_engine, schema = 'payroll') tableObj = metadata.tables.get('test.salary') colList = [Column('description',String(100)),Column('information',String(50))] tableObj.append_column(*colList) tableObj.create_column(*colList) getting an error as TypeError:create() got multiple values for keyword argument 'table' Please do the needful. create_column isn't an SQLAlchemy method as far as I know. Are you using something like sqlalchemy-migrate (http://code.google.com/p/sqlalchemy-migrate/)? If so, you'll probably get more help on their mailing list. Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Bulk creation of columns
On Sep 21, 2011, at 6:30 AM, pravin battula wrote: Hi, How can i create columns in bulk? I tried as below but doesn't work. migrate_engine = create_engine('mysql://root:root@localhost/ payroll', echo=False) metadata = MetaData(bind = migrate_engine) metadata.reflect(bind = migrate_engine, schema = 'payroll') tableObj = metadata.tables.get('test.salary') colList = [Column('description',String(100)),Column('information',String(50))] tableObj.append_column(colList) tableObj.create_column(colList) You need to create new Column objects for each table because the table objects take ownership of the passed in columns. Cheers, M -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.