Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Created June 28, 2014 13:04
Show Gist options
  • Save inklesspen/c02c373510184c5b1643 to your computer and use it in GitHub Desktop.
Save inklesspen/c02c373510184c5b1643 to your computer and use it in GitHub Desktop.
jon=# \d foo
Table "public.foo"
Column | Type | Modifiers
--------+-----------------------+--------------------------------------------------
id | integer | not null default nextval('foo_id_seq'::regclass)
key | character varying(20) | not null
value | character varying | not null
Indexes:
"foo_pkey" PRIMARY KEY, btree (id)
"foo_key_key" UNIQUE CONSTRAINT, btree (key)
jon=# \d bar
Table "public.bar"
Column | Type | Modifiers
--------+-----------------------+--------------------------------------------------
id | integer | not null default nextval('bar_id_seq'::regclass)
key | character varying(20) | not null
value | character varying | not null
Indexes:
"bar_pkey" PRIMARY KEY, btree (id)
"bar_key_key" UNIQUE CONSTRAINT, btree (key)
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, Unicode
from sqlalchemy.dialects.postgresql import INTEGER
meta = MetaData()
foo = Table('foo', meta,
Column('id', Integer, primary_key=True),
Column('key', Unicode(20), unique=True, nullable=False),
Column('value', Unicode, nullable=False))
bar = Table('bar', meta,
Column('id', INTEGER, primary_key=True),
Column('key', Unicode(20), unique=True, nullable=False),
Column('value', Unicode, nullable=False))
engine = create_engine("postgres://[email protected]/jon")
meta.create_all(bind=engine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment