I apologize for my poorly posted previous message. Here is the whole
thing hopefully.
I have been going through the recipe and I do have working example.
I have created a wrapper class for the session and to house the
entities. I'd like to stitch the session back into the entity so that
the entity has a query attribute once again. Is this possible (or
better yet: easy)?
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import create_engine
from model import *
class dbFile:
def __init__(self, filename , echo=False ):
self.filename
self.uri_db = 'sqllite:///' + filename
self.engine = create_engine(self.uri_db, echo=echo)
self.session = scoped_session(
sessionmaker(autoflush=True,
autocommit=True,
bind=self.engine))
for e in entities:
dbFile.__dict__[e.__name__] = e
def toXML(self):
print "<db filename='%s'>" % (self.filename,)
for e in entities:
e.toXMLself.session)
# I want to use :
# e.toXML() # ie. a linked in session.
print "</db>"
if __name__ == '__main__':
print "Here we go"
# Fully pathed
d1 = dbFile("/tmp/one.db")
# Relatively pathed
d2 = dbFile("two.db")
# This works
d2.session.query(d2.Scale).all()
# I want this again:
# d1.Scale.query.all()
^^^^^^^^^^^^^^^^^^^^^^^
Any pointers?
Thanks,
Nicky
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---