Iain Duncan <iainduncanli...@gmail.com> writes: > Hi folks, I've been googling and cargo culting to no avail here, hope > someone can help. > I'm trying to get an app running on MySQL on OS X, that was running fine on > MySQL on Linux. > > The issue is I have some large composite primarky keys: > > class VarTrigger(Base): > "assoc table that associates actions when a var is set" > __tablename__ = "var_trigger" > # actual primary key is var_id, p_value > var_id = Column(Integer, ForeignKey("var.id"), nullable=True, > primary_key=True) > p_value = Column( String(255), primary_key=True, nullable=False ) > ... > > When I try to create the tables I'm getting the following: > > qlalchemy.exc.OperationalError: (OperationalError) (1709, 'Index column > size too large. The maximum column size is 767 bytes.') >
Most probably, the MySQL settings differ from one installation to the other, and on OS X the database has been created with UTF-8 as default codec. At that point, MySQL considers that each "character" in a string *may* consume up to 3 (or 4, depending on the exact codec) bytes, so it assume that your "p_value" string needs 255*3 bytes, that summed with "var_id" size exceeds maximum allowed index entry size. There may be some setting to change that limit. > I've been trying out things like changing character collation and so one > with no luck. Collation is different from the encoding: the former defines the ordering rules, the latter the actual content encoding (that is, how the data is written to permanent storage). hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.