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_id), FOREIGN KEY(user_id) REFERENCES "user" (id) ON DELETE SET NULL ) and I see in pgsql modifiers "not null": \d user_ip Table "public.user_ip" Column | Type | Modifiers ---------+---------+----------- user_id | integer | not null Indexes: "user_ip_pkey" PRIMARY KEY, btree (user_id) Foreign-key constraints: "user_ip_user_id_fkey" FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE SET NULL
Can sqlalchemy allow nullable primary_keys? Or table without primary key? Thanks. On Fri, Nov 11, 2011 at 12:54 AM, Michael Bayer <mike...@zzzcomputing.com>wrote: > > 1. time_last = Column(DateTime, nullable=True, server_default=text('NULL')) > > 2. all columns in a relational database default to NULL so not sure why > you'd need to do this. > > -- 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.