Re: [sqlalchemy] defining a relationship with IS NOT

2014-04-15 Thread Richard Gerd Kuesters

interesting, i didn't knew that :D

i was using shomething like (for softwares such as st2, which has pep8 
checking):


## variables

NULL = None  # f**k pep-8
TRUE = True  # f**k pep-8
FALSE = False  # f**k pep-8

so, somecol != NULL is not acused as violating pep8, lol.

well, just for fun :)

On 04/15/2014 02:44 AM, Michael Bayer wrote:

there's an isnot() operator, use that


On Apr 14, 2014, at 7:17 PM, Jonathan Vanasco jonat...@findmeon.com 
mailto:jonat...@findmeon.com wrote:



I'm on postgres and have a boolean column that allows NULL values.

I need to create a relationship between 2 ORM classes , where there 
is a filter that states IS NOT TRUE.


The ORM likes these 2 commands :
photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is 
http://Photo.is_deletion_scheduled != True ))
  photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is 
http://Photo.is_deletion_scheduled  True ))


however they don't compare correct in Postgresql.  I need this to 
work, however the mapper doesn't like it:
photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is 
http://Photo.is_deletion_scheduled IS NOT True ))


if I were doing a column comparison, I would do
Photo.is http://Photo.is_deletion_scheduled.op('IS NOT')(True)

anyone have an idea ?

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


Re: [sqlalchemy] defining a relationship with IS NOT

2014-04-15 Thread Wichert Akkerman

On 15 Apr 2014, at 13:25, Richard Gerd Kuesters rich...@humantech.com.br 
wrote:

 interesting, i didn't knew that :D
 
 i was using shomething like (for softwares such as st2, which has pep8 
 checking):
 
 ## variables
 
 NULL = None  # f**k pep-8
 TRUE = True  # f**k pep-8
 FALSE = False  # f**k pep-8

You can also use sqlalchemy.sql.null(), sqlalchemy.sql.true() and 
sqlalchemy.sql.false() 

Wichert.

-- 
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] defining a relationship with IS NOT

2014-04-15 Thread Richard Gerd Kuesters

yeah, that's why I shared this :) good to know, i'll use that from now on ;)

my best regards,
richard.


On 04/15/2014 09:32 AM, Wichert Akkerman wrote:


On 15 Apr 2014, at 13:25, Richard Gerd Kuesters 
rich...@humantech.com.br mailto:rich...@humantech.com.br wrote:



interesting, i didn't knew that :D

i was using shomething like (for softwares such as st2, which has 
pep8 checking):


## variables

NULL = None  # f**k pep-8
TRUE = True  # f**k pep-8
FALSE = False  # f**k pep-8


You can also use sqlalchemy.sql.null(), sqlalchemy.sql.true() and 
sqlalchemy.sql.false()


Wichert.

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


Re: [sqlalchemy] defining a relationship with IS NOT

2014-04-15 Thread Jonathan Vanasco
i'll try this later.

i ended up 'monkeypatching' all these relationships onto the classes at the 
end of my models.py file , using the non-string column syntax.  would have 
preferred to keep the entire class definition, together.. but I documented 
everything.  

-- 
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] defining a relationship with IS NOT

2014-04-14 Thread Jonathan Vanasco
I'm on postgres and have a boolean column that allows NULL values.

I need to create a relationship between 2 ORM classes , where there is a 
filter that states IS NOT TRUE.  

The ORM likes these 2 commands :
photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled != True ))
photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled  True ))

however they don't compare correct in Postgresql.  I need this to work, 
however the mapper doesn't like it:
photo = sa.orm.relationship(Photo, primaryjoin=and_( 
Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled IS NOT True ))

if I were doing a column comparison, I would do
Photo.is_deletion_scheduled.op('IS NOT')(True)

anyone have an idea ?

-- 
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] defining a relationship with IS NOT

2014-04-14 Thread Michael Bayer
there's an isnot() operator, use that


On Apr 14, 2014, at 7:17 PM, Jonathan Vanasco jonat...@findmeon.com wrote:

 I'm on postgres and have a boolean column that allows NULL values.
 
 I need to create a relationship between 2 ORM classes , where there is a 
 filter that states IS NOT TRUE.  
 
 The ORM likes these 2 commands :
 photo = sa.orm.relationship(Photo, primaryjoin=and_( 
 Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled != True ))
 photo = sa.orm.relationship(Photo, primaryjoin=and_( 
 Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled  True ))
 
 however they don't compare correct in Postgresql.  I need this to work, 
 however the mapper doesn't like it:
 photo = sa.orm.relationship(Photo, primaryjoin=and_( 
 Useraccount.photo_id==Photo.id , Photo.is_deletion_scheduled IS NOT True ))
 
 if I were doing a column comparison, I would do
 Photo.is_deletion_scheduled.op('IS NOT')(True)
 
 anyone have an idea ?
 
 -- 
 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.

-- 
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] Defining a relationship without a foreign key constraint?

2011-03-15 Thread recurse
I'm wondering if there is a way to define a relationship without
creating an associated foreign key constraint in the database.  It
seems like relationship() requires me to define a foreign key, and
that in turn automatically creates a foreign key constraint.  I'm
currently using the declarative syntax to define my tables.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Defining a relationship without a foreign key constraint?

2011-03-15 Thread Mike Conley
The foreign key and join condition can be specified as part of the relation
definition without having the foreign key existing in the database

class User(Base):
__tablename__ = 'users'
logon = Column(String(10), primary_key=True)
group_id = Column(Integer)

class Group(Base):
__tablename__ = 'groups'
group_id = Column(Integer, primary_key=True)
group_nm = Column(String(10))
users = relation('User', backref='grp',
primaryjoin='User.group_id==Group.group_id',
foreign_keys='User.group_id')


-- 
Mike Conley

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.