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

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] default NULL

2011-11-10 Thread Michael Bayer
On Nov 10, 2011, at 2:09 AM, lestat wrote: > How I can add default NULL for column? > > class UserIp(db.Model, UnicodeMixin): >__tablename__ = 'user_ip' > >user_id = db.Column(db.Integer, db.ForeignKey('user.id'), > primary_key=True, nullable=True, server_default=None) >ip = db.Colu

[sqlalchemy] default NULL

2011-11-10 Thread lestat
How I can add default NULL for column? class UserIp(db.Model, UnicodeMixin): __tablename__ = 'user_ip' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True, nullable=True, server_default=None) ip = db.Column(postgres.CIDR, nullable=False, server_default='127.0.0.