¿Por qué no funciona el valor de columna predeterminado de sqlalchemy?
Estoy usando Postgresql 9.1 y SQLAlchemy 0.9.
El problema es, 'por defecto = 10'no funciona.
Mi código:
conn_str = 'postgresql://test:pass@localhost/test'
engine = create_engine(conn_str)
metadata = MetaData(bind=engine)
cols=[]
cols += [Column('Name', VARCHAR(20), primary_key=True, nullable=False)]
cols += [Column('age', INT, default=10, nullable=False )]
Table('t1', metadata, *cols)
metadata.create_all(engine)
psql:
test=> \dS t1
Table "public.t1"
Column | Type | Modifiers
--------+-----------------------+-----------
Name | character varying(20) | not null
age | integer | not null
Indexes:
"t1_pkey" PRIMARY KEY, btree ("Name")
Lo intenté con una declaración SQL directamente y debería verse así:
test=> \dS t2
Table "public.t2"
Column | Type | Modifiers
--------+-----------------------+------------
Name | character varying(10) | not null
age | integer | default 10
Indexes:
"t2_pkey" PRIMARY KEY, btree ("Name")
¿Qué estoy haciendo mal?