Hello.

I have a table with schema:

name: users
fields:  id int, name text, start datetime, end datetime
primary key: id, start, end

This is kind of a historical table, where each row defines separate 
"historical version" of an object. There are a single business User entity 
(model) with possibly many historical versions.

Such table structure makes it very hard to define relationships and work 
with related objects. Also it is hard to work with "current" version of 
User entity, because to retreive it we need to query it with "now() between 
start and end" constraint.

So i thought that maybe i can create a view for that table that will hold 
only current versions and map that view onto User entity to hide all 
historical complexities and compound PK from sqlalchemy. 

The question: is it possible to implement a mapping that will read from 
view but write into real table?

For example, view can have fields *id* (pk) and *name*.

I know that there are great examples of versioning with sqlalchemy but i 
want to hide non-functional implementation details from my business 
code/entities with view.

Thanks!

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to