KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When writing SQLAlchemy models for a pre-existing database, how much information about a table do I have to give? Consider this table which is part of a 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 sufficient to use it: class Entity(Base): __tablename__ = 'entities' id = Column('id', Integer, primary_key=True) dn = Column('dn', String(100)) But of course its missing the UNIQUE, AUTO_INCREMENT, Engine and COLLATE information. Does SQLAlchemy care about these? Of course I could use Reflection, but I would rather not due to consistency reasons.
Tags (comma-separated)
Save Edits
Cancel