|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hi.
The issue is that I'm using MySQL to store sessions. In order to store objects for a session, I'm serialzing these objects. Something like: Tbl: Session Fields : SessID as varchar (PK) SessStart varchar (Session starting time) SessTimeToLive int ( in seconds) SessInfo -> the actual information stored in the session I thought about 2 implementation and I don't know which one is better, or wether there much better implementation than these: 1. Storing serialized data inside "SessInfo" as an xml doc In orde to retrieve, I load it to DOM, Find the element by element name, and de-serializing it's content. 2. Storing serialized data inside dictionary(value), and then serailizing the whole dictionary. for example in order to retrieve session data according to a key: in the "SessInfo" there is currently -----serialized data----- so: de-serialize "SessInfo" -> {key1 : serialized value, key2 : serialized value} get serialized value from key de-serialize value Hope I explained it good Thank you very much Roy |
|
#2
|
|||
|
|||
|
Just use one of Python's many serialization modules: cPickle and/or shelve would be most appropriate here.
|
|
#3
|
|||
|
|||
|
Quote:
I am wondering what is the best way to actually store the serialized data in the DB ( xml that containes serialized data or maybe serialized dictionary) , not how to serialize it. |
|
#4
|
||||
|
||||
|
I'd probably go for the dictionary, mainly because it seems like it'll be more efficent than parsing an XML document to get the data. Plus pickeling a dictionary is infinatly easier
![]() Mark. |
|
#5
|
|||
|
|||
|
Quote:
Thanks Mark. I'll try that |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Accessing serialized data on DataBase |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|