Hello,

P.S. Definitions:

class Reservation(object):
     def __init__(self, startdate, enddate, status, bneed, nhwrep):
         self.start_date = startdate
         self.end_date = enddate
         self.status = status
         self.businessneed = bneed
         self.notetohwrep = nhwrep

class Host(object):
     def 
__init__(self,IP,HostName,Location,Additional_info,Column_11,Column_12,Username,Password,Alias,Shareable,Shareable_between_projects,Notes,CPU,RAM,Column_23,Batch,ASSET,Owner,SSH_KEY_PRESENT,Machine_Type_Model,MAC_ADDRESS_ETH_0,Physical_Box,Up_n_running,Available):
         self.ip = IP
         self.hostname = HostName
         self.location = Location
         self.additional_info = Additional_info
         #self.End_Date = End_Date
         self.column_11 = Column_11
         self.column_12 = Column_12
         self.username = Username
         self.password = Password
         self.alias = Alias
         self.shareable = Shareable
         self.shareable_between_projects = Shareable_between_projects
         self.notes = Notes
         self.cpu = CPU
         self.ram = RAM
         self.batch = Batch
         self.asset = ASSET
         self.owner = Owner
         self.ssh_key_present = SSH_KEY_PRESENT
         self.machine_type_model = Machine_Type_Model
         self.mac_address_eth_0 = MAC_ADDRESS_ETH_0
         self.physical_box = Physical_Box
         self.up_n_running = Up_n_running
         self.available = Available



hosts_table = Table('hosts',md,
Column('id',Integer,primary_key=True),
Column('ip',String),
Column('hostname',String),
Column('location',String),
Column('architecture_id',Integer,ForeignKey('architecture.id')),
Column('os_kind_id',Integer,ForeignKey('os_kind.id')),
Column('os_version_id',Integer,ForeignKey('os_version.id')),
Column('additional_info',String),
#Column('End_Date',SLDate),
Column('column_12',String),
Column('column_13',String),
#Column('email_id',Integer,ForeignKey('email.id')),
Column('username',String),
Column('password',String),
Column('alias',String),
Column('virtualization_id',Integer,ForeignKey('virtualization.id')),
Column('shareable',SLBoolean),
Column('shareable_between_projects',SLBoolean),
Column('notes',String),
Column('cpu',String),
Column('ram',String),
Column('column_24',String),
Column('batch',String),
Column('asset',String),
Column('owner',String),
Column('ssh_key_present',String),
Column('machine_type_model',String),
Column('mac_address_eth_0',String),
Column('physical_box',SLBoolean),
Column('up_n_running',SLBoolean),
Column('available',SLBoolean),
Column('project_id',Integer,ForeignKey('project.id')))

reservation_table = Table('reservation', md,
Column('id',Integer,primary_key=True),
Column('start_date',SLDate),
Column('end_date',SLDate),
Column('status', String),
Column('businessneed', String),
Column('notetohwrep',String),
Column('email_id',Integer,ForeignKey('email.id')),
Column('project_id',Integer,ForeignKey('project.id'))
)

reservation_hosts_assoc_table = Table('reservation_hosts', md,
Column('reservation_id',Integer,ForeignKey('reservation.id')),
Column('host_id',Integer,ForeignKey('hosts.id'))
)

mapper(Reservation, reservation_table,
properties={'email':relation(Email,order_by=Email.id),
'project':relation(Project, order_by=Project.id),
'hosts':relation(Host, 
secondary=reservation_hosts_assoc_table,backref='reservation')
}
)

mapper(Host, hosts_table,
properties={'architecture':relation(Architecture,
order_by=Architecture.id, backref='hosts'),
'os_kind':relation(OS_Kind, order_by=OS_Kind.id, backref='hosts'),
'os_version':relation(OS_version, order_by=OS_version.id,backref='hosts'),
'virtualization':relation(Virtualization,order_by=Virtualization.id, 
backref='hosts'),
'project':relation(Project, order_by=Project.id, backref='hosts'),
'reservations':relation(Reservation,secondary=reservation_hosts_assoc_table, 
backref='host_reservations')
})


Regards,
mk


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to