Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created February 3, 2017 19:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kracekumar/322a2fd5ea09ee952e8a7720fd386184 to your computer and use it in GitHub Desktop.
Save kracekumar/322a2fd5ea09ee952e8a7720fd386184 to your computer and use it in GitHub Desktop.
Return JSON natively from Postgres in Python
CREATE TABLE author (
id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE book (
id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
author_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(author_id) REFERENCES author (id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment