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=' 127.0.0.1/32') and it raise error: ArgumentError: Mapper Mapper|UserIp|user_ip could not assemble any primary key columns for mapped table 'user_ip' Thanks! On Fri, Nov 11, 2011 at 2:35 PM, Wichert Akkerman <wich...@wiggy.net> wrote: > 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 be null. The PostgreSQL documentation describes > this as follows: "Technically, a primary key constraint is simply a > combination of a unique constraint and a not-null constraint.". > > I suggest that you replace primary_key=True with unique=True. > > Wichert. > > -- 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.