Re: [sqlalchemy] Table Views

2015-03-27 Thread Jonathan Vanasco

SqlAlchemy doesn't natively support traditional database views.  They're 
often handled by reflecting an existing database view as a database table 
(http://docs.sqlalchemy.org/en/latest/core/reflection.html#reflecting-views). 
 There are also some API functions that deal with getting view metadata 
out of the backend.

If you're trying to map columns from different tables onto a single class, 
there is an extension called association_proxy that will let you do that.

-- 
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/d/optout.


[sqlalchemy] Table Views

2015-03-26 Thread Philip Martin
I am beginning to familiarize myself with basic concept in sqlalchemy.  One 
question I am still trying to wrap my head around is creating a table view.

In terms of the problem I am trying to solve, I am trying to setup schemas 
particularly related to financial reference data.  The data doesn't change 
very often, but I want to setup a good schema where changing one table row 
changes the data in the whole system, but also create table views the most 
useful aspects of the data reside in one table.

For example, say we have something like:

security
 id
 sec_type
 ticker
 cusip
 sedol
 description
 exchange.id
 country.code
 
country
 code
 name

exchange
 code
 name
 country.code

sec_type
 code
 description
 country.code
 currency.code

*From this, I would like to create a table view with something like:*

security_view
 id
 ticker
 cusip
 sedol
 description
 exchange.name
 sec_type.code
 sec_type.description
 sec_type.currency
 country.name 

The table view will be for viewing the whole table in applications, and 
mapping data between applications.  I don't want a security objects in 
Python have attributes that are also objects in these cases, but instead 
act as just another data column(think pandas DataFrames).

There's going to be more tables and fields that map to this view, but I am 
trying to understand the best way in sqlAlchemy to create these types of 
views?

-- 
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/d/optout.


Re: [sqlalchemy] Table Views

2015-03-26 Thread Richard Gerd Kuesters | Pollux
you can use a select as a mapped object if you want, but i don't know if 
that's what you're looking for.



On 03/26/2015 01:54 PM, Philip Martin wrote:
am trying to setup schemas particularly related to financial reference 
data.  The data doesn't change very often, but I want to setup a good 
schema where changing one table row changes the data in the whole 
system, but also create table views the most useful aspects of the 
data reside in one table.


For example, say we have something like:


--
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/d/optout.