i want to add a composite index to the class inherited from
declarative_base
I tried this,
class MyClass:
__tablename__ = 'my_table'
id = Column(Integer, primary_key=True)
name = Column(String, nullable=False)
type = Column(String, nullable=False)
__table_args__ = (
Index('ix_name_type','name','type',unique=True)
)
gave me an error,
File "/m2svn/trunk/src/model/MyClass.py", line 32, in MyClass
__table_args__ = (
File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py", line 1461, in __init__
self._init_items(*columns)
File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py", line 1465, in _init_items
self.append_column(_to_schema_column(column))
File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py", line 2145, in _to_schema_column
raise exc.ArgumentError("schema.Column object expected")
sqlalchemy.exc.ArgumentError: schema.Column object expected
On Aug 21, 3:23 am, Michael Bayer <[email protected]> wrote:
> this is usually accomplished using "Index()". see the metadata docs
> for details.
>
> On Aug 20, 2009, at 12:35 PM, rajasekhar911 wrote:
>
>
>
> > Hi
>
> > Is it possible to add index to my table using sqlalchemy?
> > Or should i do it directly on the database?
>
> > Thanks..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---