ok, let's see if I can explain the scenario better :D

first, i'm using schematics <http://schematics.readthedocs.org/> to define "arbitrary" models for message exchange between processes, ui, events and so on. based on a json schema (that the schematics model generates), i'm able to store data on the database using a relatively sparse system of tables that compose my eav system -- not a good system (eav), but sometimes necessary (and i have bad experiences with nosql databases).

so, given a composed model with data, i can populate the database and retrieve data from it (i'm using postgres btw). so far so good.

now, i would like to "query" them :) let's suppose i have the following (simple) model (from schematics example):
*
* *class Person(Model):**
**    name = StringType(required=True)**
**    website = URLType()*

with that, i know that StringType should go to StringDataTable, URLType to StringDataTable, Boolean to BooleanTable, and so on. using some sql filtering, i can retrieve all values that represents the field "name" from the model "Person", but that's quite not viable if I want my devs to work with eav when needed instead of going nuts because someone created a hundred tables to store just lines of data on each one.

so, if could extend "Model" or create a extension that maps my class and then can be used in the "sqlalchemy way" of querying, it would be awesome. let's say:
*
**session.query(Person).filter(Person.website == None).all()*

i know it'll give me some hard work to do it, but I'm willing to give it a try :)


my best regards,
richard.



On 12/04/2013 05:51 PM, Michael Bayer wrote:
you’d need to show me a minimal case of the composed model in question and what kind of operation you want to do.

you basically have to write your own comparators and such that produce the correct SQL. it tends to not be that easy of a task.

On Dec 4, 2013, at 2:07 PM, Richard Gerd Kuesters <rich...@humantech.com.br <mailto:rich...@humantech.com.br>> wrote:

thanks Mike!

it is good to know this :) can you give me a hint from where do i to start? :)

best regards,
richard.


On 12/04/2013 04:38 PM, Michael Bayer wrote:
sure it can. you’d just need to be defining accessors and methods for all the things it needs to do in each case - these accessors would use the components to produce the appropriate SQL constructs as needed.



On Dec 4, 2013, at 1:23 PM, Richard Gerd Kuesters <rich...@humantech.com.br <mailto:rich...@humantech.com.br>> wrote:

hi all!

i was wondering if there is a way to create "fake" models, in which i can query the way I want and map methods the way i want.

let's say i have a common object that is made in pieces to the database (similar to the eav pattern), stored in multiple tables. now, backwards, i have to make a whole mess of code to bring the object with data again, but it works fine, so far.

what I really wanted was to use this class like a mapped model, using session.query, filters and stuff, abstracting its keys to other attributes and conditionals for the *real* table structure.

the problem is: can it be made?


thanks in advance,
richard.

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to