On Oct 30, 2009, at 8:45 PM, Ted Dziuba wrote:

> Hi,
>
> I am trying to create an index on a fixed-width prefix of a VARCHAR  
> column in MySQL. In my Alchemy model, I have the following:
>
> url = Column(String(4096))
>
> And I know that there an index = True parameter I can pass to the  
> Column constructor, but that will attempt to index the entire field.  
> MySQL restricts the length of a VARCHAR index, so I only want to  
> index the first 32 characters. In MySQL, the clause at table  
> creation time would be:
>
> KEY `url` (`url`(32))
>
> But how do I get alchemy to generate this clause when it creates the  
> table?

I'm not familiar with that syntax, but assuming it can be generated  
via CREATE INDEX or ALTER outside of the CREATE TABLE itself, I would  
apply it using a DDL() construct that is associated with the "after- 
create" event of the Table object, containing the full MySQL-specific  
statement needed..


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

Reply via email to