[Grok-dev] Automatically execute a procedure on saving/loading from Sql database with MeGrok and SQLAlchemy
white.lists at gmail.com
Fri Oct 22 18:36:57 EDT 2010
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 meGrok/sqlalchemy to have my classes stored over a RDBMS (MySql)
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 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()"... :-)
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Grok-dev