Hi all,

My name is Chris Norman, and I am a hobbyist programmer in the UK.


Firstly, please let me thank the creators for a truly wonderful piece of 
software! I was starting my application and coding the SQL by hand, which 
was a pain considering I don’t really know SQL all that well. SQLAlchemy 
actually gets around a load of problems I was having with the initial idea.


Anyways, now for my problem:


I’m trying to make a Pythonic sort of copy (with the view to splitting off) 
of the popular Lambda MOO server. I’m using a proper database backend, so 
that certain things which are a major pain in MOO will become much easier. 
That, and it would be cool to have a threaded version of MOO, without all 
the annoying bits.


Anyways, my question is this:

I created my tables with declarative and all that - works fine in fact. But 
just tonight I added a new column to one table. When I did 
Base.metadata.create_all(), I thought SQLAlchemy would realise there’s an 
added column, and add it to the database for me, but it hasn’t. Is there a 
way to make it do that so I don’t have to do any clever things when the 
server loads to check for differences between the database and the objects 
I’ve created?


Secondly, and sort of incidentally because I’ve already worked around this, 
is there any way to return an object from an id without having to use 
session.get? I kind of have this in mind:


class Object(Base):

 """My standard object."""

 __tablename__ = 'objects'

 id = Column(Integer, primary_key = True, nullable = False) # The primary 
key.

 location = Column(MagicType, default = None) # Location field.


The MagicType would contain an integer database-side, like 1, or 2, 
whatever, but would map directly to the object with that id.


I have gotten round this by using:

@property

def location(self):

 return self.location.id if self.location else None


@location.setter

def location(self, value):

 self._location = value.id if value else None


But I was wondering if there was a type which would do this with less 
properties being defined?


Cheers for all the help, and thanks once again for SLQAlchemy, it looks 
mighty fine to me! :-)


Cheers, and take care.


Chris Norman.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to