Jan Dittberner
dea15a6c4f
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@242 a67ec6bc-e5d5-0310-a910-815c51eb3124
32 lines
856 B
Python
32 lines
856 B
Python
#!/usr/bin/python
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
from sqlalchemy import *
|
|
|
|
meta = BoundMetaData('postgres://jan:heyyou97@localhost:5432/jan')
|
|
domains_table = Table('domains', meta, autoload=True)
|
|
records_table = Table('records', meta, autoload=True)
|
|
|
|
class Domain(object):
|
|
def __repr__(self):
|
|
return "%s(%r,%r)" % (
|
|
self.__class__.__name__, self.id, self.name)
|
|
|
|
class Record(object):
|
|
def __repr__(self):
|
|
return "%s(%r,%r,%r)" % (
|
|
self.__class__.__name__, self.id, self.domain_id, self.domain)
|
|
|
|
recordmapper = mapper(Record, records_table)
|
|
domainmapper = mapper(Domain, domains_table, properties = {
|
|
'records': relation(Record, backref='domain')
|
|
})
|
|
|
|
session = create_session()
|
|
query = session.query(Domain)
|
|
|
|
domain = query.get_by(name='dittberner.info')
|
|
if domain:
|
|
print domain.records
|
|
|
|
session.flush()
|