Re: [sqlalchemy] Specifying foreign keys in relationship

2011-11-11 Thread Michael Bayer
that's a bug as the example earlier is almost the same thing w/ declarative. ticket #2323 On Nov 11, 2011, at 10:48 AM, Vlad K. wrote: > > 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,

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 Multip

Re: [sqlalchemy] Specifying foreign keys in relationship

2011-11-11 Thread Michael Bayer
On Nov 11, 2011, at 3:46 AM, Vlad K. wrote: > > 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

Re: [sqlalchemy] default NULL

2011-11-11 Thread Gunnlaugur Briem
You can create such a table, yes, if you are sure you should: from sqlalchemy import * e = create_engine('sqlite:///') t = Table('foo', MetaData(e), Column('bar', Text)) t.create() (or skip the last call if you are referencing an existing table in the DB) The ORM part of SQLAlchemy does require

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=' 1

[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 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 ', ondelete='SET NULL'), primary_key=True, nullable=True, server_default=text('NULL')) A primary key can never

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

Re: [sqlalchemy] query returns a non-result?

2011-11-11 Thread Chris Withers
On 04/11/2011 19:04, Michael Bayer wrote: Anyway, SQLAlchemy raises the error you see if you call fetchone()/all() on a result set where cursor.description is not present. Why query(X).with_lockmode('update').all() is doing this appears to be some bug in your DBAPI, because all() emits a SELE