[Tutor] Finding an object by ID
Andre Engels
andreengels at gmail.com
Thu May 3 07:39:31 CEST 2007
It seems to me that this is is an issue that is not resolved in
Python, but in your database's language. Every database language
that's word the name has a command like "get the record that has
such-and-such value for this-and-that property". What command it is,
depends on the database. Or am I now completely misunderstanding your
meaning of the word 'database'?
2007/5/2, Dj Gilcrease <digitalxero at gmail.com>:
> I was wondering if it was possible to find and object by it's ID.
>
> what I want to do is something like
>
> def incomingConnection(self, stuff):
> (incSock, incAdder) = self.__sock.accept()
>
> #Add the adder socket ID and other info to a DB
>
> def sendMessage(self, adder, message):
> #query the DB and get the socket ID stored there
>
> sock = getSocketByID(sockID)
>
> #do my send data
>
>
>
> The reason I want to do this is right now I store all the data in a
> dict of class
>
> eg
> class connections:
> def __init__(self, *args, **kwargs):
> self.sock = args[0]
> self.myotherdata = stuff
> ...
>
>
> def incomingConnection(self, stuff):
> (incSock, incAdder) = self.__sock.accept()
> self.conns[incAdder] = connections(incSock, ...)
>
>
> This takes up about 20 megs per person connecting, which is very high
> IMHO, and I am hoping by storing all the data in the database and only
> retrieving it when I need it will help reduce the memory footprint of
> my server
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
Andre Engels, andreengels at gmail.com
ICQ: 6260644 -- Skype: a_engels
More information about the Tutor
mailing list