Changes between Version 3 and Version 4 of FAQ
- Timestamp:
- 12/15/07 11:10:09 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FAQ
v3 v4 8 8 #!python 9 9 class Person(Entity): 10 id = Field(Integer, primary_key=True)10 person_id = Field(Integer, primary_key=True) 11 11 firstname = Field(Unicode(30)) 12 12 surname = Field(Unicode(30)) 13 13 }}} 14 14 15 This also works if your primary key is composed of several fields: 16 17 {{{ 18 #!python 19 class Person(Entity): 20 firstname = Field(Unicode(30), primary_key=True) 21 surname = Field(Unicode(30), primary_key=True) 22 }}} 23 24 15 25 === Is there a way to declare uniqueness constraints? === 16 26 17 Yes, you can use the `using_table_options` statement . Here is an example:27 Yes, you can use the `using_table_options` statement in combination with SQLAlchemy's `UniqueConstraint`. Here is an example: 18 28 {{{ 19 29 #!python 30 from sqlalchemy import UniqueConstraint 31 20 32 class Person(Entity): 21 33 firstname = Field(Unicode(30))
