Piper Pickling?
Mike C. Fletcher
mcfletch at rogers.com
Thu Sep 12 22:24:42 EDT 2002
Strangely enough, I just spent the afternoon working to plan something
like this. I believe this is called an object-relational adapter in
case you want to look for other implementations (there's lots for Java).
Basically, this is most easily done with objects that have
static-typed properties (such as I have in the basicproperty package).
You can construct a schema from the class+properties.
I'd estimate this will take a few weeks of solid programming to make
work properly (i.e. make the data-type mappings all reasonable and
efficient with a decent interface).
Only relevant pre-cursor project I've seen is Python Data Object (PyDO)
which is part of the SkunkWeb system. That system doesn't solve the
"create schema from object" problem AFAICS, and it's that problem that
I'm interested in solving.
For instance, with a data-model like this:
Event:
mxDateTime startDate
mxDateTime stopDate
str name
User user
Collection{type Resource} resources
Resource:
str name
User:
str name
(simplified example from one of my projects), you'd want the data-store
to create 3 class-specific tables with the Event table having a resource
sub-table for the one-to-many relationship. You'd want it to manage all
the persistentIDs, and to properly re-constitute property values on
access to be references to objects (rather than persistentIDs).
The model I'm currently laying out seems quite capable of supporting
this, though there will need to be some additions to the basicproperty
class to support selecting among the various many-to-one / one-to-many /
one-plus-sub-key-to-many / etceteras data models for certain properties.
The thing is, to be really useful, you need to make a lot of simplifying
assumptions (such as that all objects of a type/class have the same
data-storage requirements). I can make those assumptions in my apps,
but the result won't allow for anything like the full range of Python's
dynamic nature.
Anyway, I'm going back to my SQL lessons now :),
Mike
Robert Oschler wrote:
> Forgive me :)
>
> If Peter Piper pickles a peck of Python packages, can he pack the pickled
> Python peckers in a proper packing place?
>
> Translated: Anybody seen a module that can override the standard pickling
> process and store and retrieve Python objects to a MySQL database?
>
> thx
>
> P.S. - Whell hell the language is named after the world's best comedy
> troupe, what did you expect, green eggs and spam? :)
>
>
--
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list