#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11

    Question Accessing serialized data on DataBase


    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. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Just use one of Python's many serialization modules: cPickle and/or shelve would be most appropriate here.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11
    Originally Posted by Strike
    Just use one of Python's many serialization modules: cPickle and/or shelve would be most appropriate here.
    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.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11
    Originally Posted by netytan
    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.
    Thanks Mark.
    I'll try that

IMN logo majestic logo threadwatch logo seochat tools logo