Hey,
I have a declarative table called 'Foo':
_Base = declarative_base()
class Foo(_Base):
__tablename__ = 'foo'
__table_args__ = {'mysql_engine': 'InnoDB',
'mysql_charset': 'latin1'}
id = Column(String(64), primary_key=True, autoincrement=False)
stuff = Column(Integer(11), primary_key=True, nullable=False)
Now I create Foo1 that has exactly the same definition but differs
just by the name:
class Foo1(_Base):
__tablename__ = 'foo1'
__table_args__ = {'mysql_engine': 'InnoDB',
'mysql_charset': 'latin1'}
id = Column(String(64), primary_key=True, autoincrement=False)
stuff = Column(Integer(11), primary_key=True, nullable=False)
And I need more of those (FooN with N = 10). The use case is to shard
data across several tables.
To avoid cut/n/pastes, I tried inheritance, meta-class, a type
factory and the like, but everything fails. Whether because I was
reusing the same column class objects or whether because I was
conflicting with SQLALchemy meta-class magic.
Is there any sane way to do this and avoid a crazy copy/paste ?
Cheers
Tarek
--
Tarek Ziadé | http://ziade.org
--
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.