Hi Askel...

What I'd like to accomplish is to add few more attributes and methods to
Table (or maybe override "insert/update/delete/select") to do post
processing of the Result/Row proxies and return them in different formats
such as json, yaml, xml, etc... so, while you suggestion is really neat,
I'm not sure it's enough to do what I want... Is it?

I could create my metadata obj from a bunch of extended Table object
instead of populating it from reflection, but I feel its a lot nicer to use
the real DB schema as the source for the metadata (thru reflection), than
trusting the table definitions in code to correspond exactly with the DB
schema. I have a hard time trusting that nobody will ever run an alter
table out-of-band, and not update the definitions... hehehe

Thanks!
g.


On Thu, Aug 1, 2013 at 5:35 AM, askel <dummy...@mail.ru> wrote:

> There is "column_reflect" event triggered for each column during table
> reflection. Most likely your extra functionality depends on some columns so
> I'd look at something like:
>
>
>     from sqlalchemy.event import listens_for
>
>
>     columns_to_reflect = set(('id', 'name', 'real_name',
> 'really_real_name'))
>
>     @listens_for(my_table, 'column_reflect'):
>     def column_reflected(inspector, table, column_info):
>         columns_to_reflect.remove(column_info['name'])
>         if not columns_to_reflect:
>             do_my_dirty_job(table)
>
> It does not help to have no "table_reflected" event though. May be this
> should become a feature request.
>
>
> On Wednesday, July 31, 2013 1:34:46 PM UTC-4, tiadobatima wrote:
>>
>> Hello there,
>>
>> When this application starts, we reflect the DB into a MetaData() object
>> and this is made available for everyone to use.
>> I'd like to add a few more methods to the table objects within that
>> MetaData(). Is there any easy way to extend these already
>> instantiated sqlalchemy.**schema.Table objects?
>>
>> Thanks! :)
>>
>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "sqlalchemy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sqlalchemy/EoTA-H1s-bQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>
>
>

-- 
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