Warum nicht sqlalchemy ist der Standardwert für die Spalte arbeiten

Ich bin mit Postgresql 9.1 und SQLAlchemy 0.9.

Das problem ist, 'default=10' funktioniert nicht.

Mein Code:

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")

Versuchte ich mit einem SQL-Anweisung direkt ein und es sollte so Aussehen:

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")

Was mache ich falsch?

InformationsquelleAutor Aylwyn Lake | 2013-12-03
Schreibe einen Kommentar