File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,12 +5,11 @@ verify_ssl = true
55
66[dev-packages ]
77python-dotenv =" *"
8- pylama =" *"
98
109[packages ]
1110Flask =" *"
1211Flask-SQLAlchemy =" *"
13- pymysql =" *"
12+ psycopg2-binary =" *"
1413
1514[requires ]
1615python_version = " 3.7"
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 77def 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
Original file line number Diff line number Diff line change 33class 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 )
Original file line number Diff line number Diff line change 77@app .route ('/' , methods = ['GET' ])
88def 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
Original file line number Diff line number Diff line change 44class 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" )
Original file line number Diff line number Diff line change 1- astroid == 2.1.0
21Click == 7.0
32Flask == 1.0.2
43Flask-SQLAlchemy == 2.3.2
5- isort == 4.3.4
64itsdangerous == 1.1.0
75Jinja2 == 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
178python-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
You can’t perform that action at this time.
0 commit comments