Re: [sqlalchemy] default NULL

2011-11-11 Thread Alex K
Thanks, but if I need allow nullable primary_keys it not works. I tried: user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'), primary_key=True, nullable=True, server_default=text('NULL')) it generates CREATE TABLE user_ip ( user_id INTEGER DEFAULT NULL, PRIMARY KEY

Re: [sqlalchemy] default NULL

2011-11-11 Thread Wichert Akkerman
On 11/11/2011 11:20 AM, Alex K wrote: Thanks, but if I need allow nullable primary_keys it not works. I tried: user_id = db.Column(db.Integer, db.ForeignKey('user.id http://user.id', ondelete='SET NULL'), primary_key=True, nullable=True, server_default=text('NULL')) A primary key can never

[sqlalchemy] Specifying foreign keys in relationship

2011-11-11 Thread Vlad K.
Hi, I have two models, A and B. Model B contains two foreign keys into table A, because it is a comparator model that describes certain logical interaction between two A models. However, I want model B to contain a relationship to both so I can access them through the model B instance:

Re: [sqlalchemy] default NULL

2011-11-11 Thread Alex K
Oh, sorry, my mistake. Can I create table in sqlalchemy without primary key? class UserIp(db.Model, UnicodeMixin): __tablename__ = 'user_ip' user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL')) ip = db.Column(postgres.CIDR, nullable=False, server_default='

Re: [sqlalchemy] Specifying foreign keys in relationship

2011-11-11 Thread Vlad K.
Ah, so, thanks. My logic was that I could specify which foreign_key to use for the relationship, which is basically a subset of primaryjoin condition, but in my opinion cleaner. So, that wouldn't work? I must use always use primaryjoin? I was looking at few paragraphs below, under