Wow... I just saw this... http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#sqlalchemy.types.TypeDecorator Maybe that's what I need! I'll confirm (for future questions) :-)
2010/10/25 Hector Blanco <white.li...@gmail.com> > Hello everyone. > > First of all, thank you for reading this (no matter whether you can/want to > help me or not) :-) > > Second, the question: > > I am using sqlalchemy under MeGrok (http://pypi.python.org/pypi/megrok.rdb) > to have my Python/Grok classes stored over a RDBMS (MySql) database. > > I have a Python class in which one of the fields is a list of strings. I > don't really find worthy to create a table to relate the class with the > fields (is just a list that can take certain names of days of the week) so I > was planning to store them in MySql as an string where the values would be > separated with a comma (or semicolon). > > On the other hand, is very useful to have that field as a list (in Python > classes) so here's my question: > > Is there a way to automatically execute an stored procedure (SQL > preferably, but I could also do it on the "Python" side) so when the class > is saved, that list field will be automatically joined (with whatever > separator character) and when the class (or that field) is loaded, it will > be automatically split-ed (so it will come back as a list)? > > In my brain, I have "dreamed" about something like an special type of * > sqlalchemy.Column* in which you can specify something like "*on_save = > execute this()*" and "*on_load = execute that()*"... :-) > > I also asked this very same question in the Grok-dev mail list. They > suggested me the use of decorators, which I find an interesting idea, but I > don't really know where to put a decorator to ensure that when that field is > saved, it's saved as an array, and when it's loaded, it's loaded as a list. > > Oh, and, for the record, I am a newbie with this Grok over MySql thing so > it may not make any sense what I just asked but... I had to try. > > Thank you in advance. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.