[sqlalchemy] Re: Bulk creation of columns

2011-09-21 Thread pravin battula
> You need to create new Column objects for each table because the table 
> objects take ownership of the passed in columns.
I think that is what i'm doing,creating new column objects for 2
columns and first appending it to the table object and then trying to
create those columns using create_column,please correct me if i'm
wrong.




On 21 Sep, 20:24, AM  wrote:
> 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.



[sqlalchemy] Re: Bulk creation of columns

2011-09-21 Thread pravin battula
i'm getting the below error.
'list' object has no attribute '_set_parent_with_dispatch'

On Sep 21, 3:30 pm, 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)
>
> Please do the needful.

-- 
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.