Hi,
Sorry for this meaningless subject !
I am learning SQLAlchemy and I installed version 0.4.1 few days ago.
My problem is probably easy to solve. I swear I have read a good part
of the documentation, and searched this group ! But...
Short example. Two tables :
- "languages" having a sequence as primary key and a column of unique
short names ('en', 'fr', etc.)
- "items" having a foreign key on 'language_id' (see Python code
below)
When creating a new item, it is not significant to fill the foreign
key value with a integer. I wish the mapper had a way to find it
through the unique language name :
item = Item()
item.name = 'A great item'
item.language_name = 'en'
session.save(item)
Please, how to do that ?
Cheers
--------------------------------------------------------------------------------
languages_table = Table('languages', metadata,
Column('language_id', PGInteger, Sequence('language_id_seq'),
primary_key=True),
Column('name', Unicode(), nullable=False, unique=True)
)
items_table = Table('items', metadata,
Column('item_id', PGInteger, Sequence('item_id_seq'),
primary_key=True),
Column('language_id', PGInteger,
ForeignKey('languages.language_id'), primary_key=True),
Column('name', Unicode(), nullable=False)
)
class Item(object): pass
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---