Hello Alchemystas, I have a legacy database, with a self written ORM not to fuss about. So I want to use a some more intelligent mechanism - sqlalchemy. I have written a little hibernator, that does nothing more, as to ask the database for its metadata via sqlalchemy (heron:0.4.2p3-1) and construct classes of the form:
from sqlalchemy import * from sqlalchemy.orm import mapper from dvzrv.db import sAmetaData class SrvDomainTable(object): def __init__(self,domain_name=None,srv_id=None): self.sAtablename = 'srv_domain' self.sAsrv_domain_table = Table(self.sAtablename, sAmetaData, autoload=True) self.sAmapped_srv_domain = mapper(DVZsrvDomainTable,self.sAsrv_domain_table,primary_key=[self.sAsrv_domain_table.c.domain_name]) self.domain_name = domain_name self.srv_id = srv_id I still do not have clue, how to cope with association tables. The class SrvDomainTable for example is one of those. The usage of primary key is only to test functionality. So my question is, will it suffice to use the primary key list listing all foreign keys -like this: primary_key=[self.sAsrv_domain_table.c.domain_name,self.sAsrv_domain_table.c.srv_id]. Or do I have to use it like the example in http://www.sqlalchemy.org/docs/04/mappers.html ? Regrettably I do not grasp the idea of the example up to now, left_table = Table('left', metadata, Column('id', Integer, primary_key=True)) right_table = Table('right', metadata, Column('id', Integer, primary_key=True)) association_table = Table('association', metadata, Column('left_id', Integer, ForeignKey('left.id')), Column('right_id', Integer, ForeignKey('right.id')), ) mapper(Parent, left_table, properties={ 'children':relation(Child, secondary=association_table) }) mapper(Child, right_table) because it uses only the parent mapper to some things, whereas the childmapper is unchanged.. thanks gregor -- Gregor Kling Abteilung ITS, Sachgebiet DVZ Fachhochschule Giessen Tel: 0641/309-1292 E-Mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME Cryptographic Signature