When writing SQLAlchemy models for an existing database, how much table information do I need to give? Consider this table, which is part of the MySQL database:
CREATE TABLE entities (
id INTEGER NOT NULL AUTO_INCREMENT,
dn VARCHAR(100) NOT NULL UNIQUE,
PRIMARY KEY (id)
) Engine=InnoDB, COLLATE utf8_unicode_ci;
Based on my testing, this would be enough to use it:
class Entity(Base):
__tablename__ = 'entities'
id = Column('id', Integer, primary_key=True)
dn = Column('dn', String(100))
But, of course, it lacks UNIQUE, AUTO_INCREMENT, Engine, and COLLATE information. Does SQLAlchemy mean this data?
Of course, I could use Reflection, but I would prefer not because of consistency.
source
share