Skip to content

Commit 7fd1a81

Browse files
committed
cleaned up tutorial
1 parent 19ad78f commit 7fd1a81

7 files changed

Lines changed: 27 additions & 32 deletions

File tree

Pipfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ verify_ssl = true
55

66
[dev-packages]
77
python-dotenv="*"
8-
pylama="*"
98

109
[packages]
1110
Flask="*"
1211
Flask-SQLAlchemy="*"
13-
pymysql="*"
12+
psycopg2-binary="*"
1413

1514
[requires]
1615
python_version = "3.7"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Flask-SQLAlchemy Tutorial
22

3-
![Python](https://img.shields.io/badge/Python-3.7.2-blue.svg?logo=python&longCache=true&logoColor=white&colorB=23a8e2&style=flat-square&colorA=36363e)
4-
![Flask](https://img.shields.io/badge/Flask-1.0.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=23a8e2&colorA=36363e)
5-
![PyMySQL](https://img.shields.io/badge/PyMySQL-0.9.3-red.svg?longCache=true&style=flat-square&logo=mysql&logoColor=white&colorA=36363e&colorB=4479A1)
3+
![Python](https://img.shields.io/badge/Python-v3.7.2-blue.svg?logo=python&longCache=true&logoColor=white&colorB=23a8e2&style=flat-square&colorA=36363e)
4+
![Flask](https://img.shields.io/badge/Flask-v1.0.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=23a8e2&colorA=36363e)
5+
![Psycopg2-binary](https://img.shields.io/badge/Psycopg2--Binary-v2.7.7-red.svg?longCache=true&style=flat-square&logo=PostgreSQL&logoColor=white&colorA=36363e)
66
![Flask-SQLAlchemy](https://img.shields.io/badge/Flask--SQLAlchemy-2.3.2-red.svg?longCache=true&style=flat-square&logo=scala&logoColor=white&colorA=36363e)
77

88
![Flask-SQLAlchemy Tutorial](application/static/img/flask-sqlalchemy.jpg)

application/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
def create_app():
88
"""Construct the core application."""
99
app = Flask(__name__, instance_relative_config=False)
10-
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
11-
app.config["SQLALCHEMY_ECHO"] = True
1210
db.init_app(app)
1311
app.config.from_object('config.Config')
1412

application/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class User(db.Model):
44
"""Model for user accounts."""
55

6-
__tablename__ = 'users'
6+
__tablename__ = 'flasksqlalchemy-users'
77
id = db.Column(db.Integer,
88
primary_key=True
99
)

application/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
@app.route('/', methods=['GET'])
88
def entry():
99
"""Endpoint to create a user."""
10-
new_user = User(username='myuser2',
11-
email='myuser2@example.com',
10+
new_user = User(username='myuser3',
11+
email='myuser3@example.com',
1212
created=dt.now(),
1313
bio="Because he's the hero Gotham deserves, but not the one it needs right now.",
1414
admin=False

config.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44
class Config:
55
"""Set Flask configuration vars from .env file."""
66

7-
# General
8-
TESTING = os.environ["TESTING"]
9-
FLASK_DEBUG = os.environ["FLASK_DEBUG"]
7+
# General Config
8+
SECRET_KEY = os.environ.get('SECRET_KEY')
9+
FLASK_APP = os.environ.get('FLASK_APP')
10+
FLASK_ENV = os.environ.get('FLASK_ENV')
11+
12+
# Assets
13+
LESS_BIN = os.environ.get('LESS_BIN')
14+
ASSETS_DEBUG = os.environ.get('ASSETS_DEBUG')
15+
LESS_RUN_IN_DEBUG = os.environ.get('LESS_RUN_IN_DEBUG')
16+
17+
# Static Assets
18+
STATIC_FOLDER = os.environ.get('STATIC_FOLDER')
19+
TEMPLATES_FOLDER = os.environ.get('TEMPLATES_FOLDER')
20+
COMPRESSOR_DEBUG = os.environ.get('COMPRESSOR_DEBUG')
1021

1122
# Database
12-
SQLALCHEMY_DATABASE_URI = os.environ["SQLALCHEMY_DATABASE_URI"]
13-
# SQLALCHEMY_ECHO = os.environ["SQLALCHEMY_ECHO"]
14-
# SQLALCHEMY_TRACK_MODIFICATIONS = os.environ["SQLALCHEMY_TRACK_MODIFICATIONS"]
23+
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI")
24+
SQLALCHEMY_TRACK_MODIFICATIONS = os.environ.get("SQLALCHEMY_TRACK_MODIFICATIONS")

requirements.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
astroid==2.1.0
21
Click==7.0
32
Flask==1.0.2
43
Flask-SQLAlchemy==2.3.2
5-
isort==4.3.4
64
itsdangerous==1.1.0
75
Jinja2==2.10
8-
lazy-object-proxy==1.3.1
9-
MarkupSafe==1.1.0
10-
mccabe==0.6.1
11-
pycodestyle==2.5.0
12-
pydocstyle==3.0.0
13-
pyflakes==2.1.0
14-
pylama==7.6.6
15-
pylint==2.2.2
16-
PyMySQL==0.9.3
6+
MarkupSafe==1.1.1
7+
psycopg2-binary==2.7.7
178
python-dotenv==0.10.1
18-
six==1.12.0
19-
snowballstemmer==1.2.1
20-
SQLAlchemy==1.2.17
21-
Werkzeug==0.14.1
22-
wrapt==1.11.1
9+
SQLAlchemy==1.3.1
10+
Werkzeug==0.15.1

0 commit comments

Comments
 (0)