Re: [sqlalchemy] Declarative: defining relationship and column in one line

2015-05-31 Thread Mike Bayer



On 5/31/15 6:11 AM, Fayaz Yusuf Khan wrote:

Hi,

On Tuesday, May 19, 2015 at 7:41:45 PM UTC+5:30, Michael Bayer wrote:


http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/
http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/

I had tried this one before but it looked like those columns were 
never added to the underlying table.


I just ran the magic.py example from the blog post against SQLA 1.0.4 
and it worked fine.





--
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] Declarative: defining relationship and column in one line

2015-05-31 Thread Fayaz Yusuf Khan
Hi,

On Tuesday, May 19, 2015 at 7:41:45 PM UTC+5:30, Michael Bayer wrote:


 http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/

 I had tried this one before but it looked like those columns were never 
added to the underlying table.

-- 
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] Declarative: defining relationship and column in one line

2015-05-19 Thread Paul Johnston
Hi,

Sorry if this is a FAQ, but is it possible to define a relationship and its 
column all at once. e.g. instead of:

type_id = db.Column(db.Integer, db.ForeignKey('linktype.id'))
type = db.relationship('LinkType')

Something like:

type = db.relationship('LinkType', colname='type_id')

In fact, it'd be good for the colname to default to xxx_id - although 
allow overriding.

This certainly was possible with Elixir.

Paul

-- 
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] Declarative: defining relationship and column in one line

2015-05-19 Thread Mike Bayer



On 5/19/15 6:54 AM, Paul Johnston wrote:

Hi,

Sorry if this is a FAQ, but is it possible to define a relationship 
and its column all at once. e.g. instead of:


type_id = db.Column(db.Integer, db.ForeignKey('linktype.id'))
type = db.relationship('LinkType')

Something like:

type = db.relationship('LinkType', colname='type_id')

In fact, it'd be good for the colname to default to xxx_id - 
although allow overriding.


This certainly was possible with Elixir.

this would be a many_to_one() macro.  Two examples of this are at:

https://bitbucket.org/zzzeek/pycon2014_atmcraft/src/f50cbe745a197ea7db83569283b703c418481222/atmcraft/model/meta/orm.py?at=master

the above is a modernized improvement on an older example:

http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/





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


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