Created
June 28, 2014 13:04
-
-
Save inklesspen/c02c373510184c5b1643 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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