Created
January 19, 2016 23:49
-
-
Save adarsh0806/aa42a5e9a42d99061412 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
adarshnair (master) Downloads $ python puppies.py | |
adarshnair (master) Downloads $ python puppypopulator.py | |
adarshnair (master) Downloads $ sqlite3 | |
SQLite version 3.8.4.1 2014-03-11 15:27:36 | |
Enter ".help" for usage hints. | |
Connected to a transient in-memory database. | |
Use ".open FILENAME" to reopen on a persistent database. | |
sqlite> .open puppyshelter.db | |
sqlite> .schema | |
CREATE TABLE shelter ( | |
id INTEGER NOT NULL, | |
name VARCHAR(80) NOT NULL, | |
address VARCHAR(250), | |
city VARCHAR(80), | |
state VARCHAR(20), | |
"zipCode" VARCHAR(10), | |
website VARCHAR, | |
PRIMARY KEY (id) | |
); | |
CREATE TABLE puppy ( | |
id INTEGER NOT NULL, | |
name VARCHAR(250) NOT NULL, | |
gender VARCHAR(6) NOT NULL, | |
"dateOfBirth" DATE, | |
picture VARCHAR, | |
shelter_id INTEGER, | |
weight NUMERIC(10), | |
PRIMARY KEY (id), | |
FOREIGN KEY(shelter_id) REFERENCES shelter (id) | |
); | |
CREATE TABLE profile ( | |
id INTEGER NOT NULL, | |
url VARCHAR, | |
"desc" VARCHAR, | |
special_needs VARCHAR, | |
puppy_id INTEGER, | |
PRIMARY KEY (id), | |
FOREIGN KEY(puppy_id) REFERENCES puppy (id) | |
); | |
sqlite> select * from profile; | |
sqlite> | |
//And profile worked as follows: | |
adarshnair (master) Downloads $ python | |
Python 2.7.9 |Anaconda 2.0.0 (x86_64)| (default, Dec 15 2014, 10:37:34) | |
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
Anaconda is brought to you by Continuum Analytics. | |
Please check out: http://continuum.io/thanks and https://binstar.org | |
>>> from puppies import Base, Shelter, Puppy, Profile | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment