|
10 | 10 |
|
11 | 11 |  |
12 | 12 |
|
13 | | -Connect your Flask app to a database using Flask-SQLAlchemy. This repository contains source code for the accompanying tutorial on [Hackers and Slackers](https://hackersandslackers.com/manage-database-models-with-flask-sqlalchemy/). |
| 13 | +Connect your Flask app to a database using Flask-SQLAlchemy. |
| 14 | + |
| 15 | +**Tutorial**: https://hackersandslackers.com/manage-database-models-with-flask-sqlalchemy/ |
| 16 | +**Demo**: https://flasksqlalchemy.hackersandslackers.app |
14 | 17 |
|
15 | | -Working demo here: https://flasksqlalchemy.hackersandslackers.app |
| 18 | +# Getting Started |
16 | 19 |
|
17 | | -## Installation |
| 20 | +Get set up locally in two steps: |
18 | 21 |
|
19 | | -**Installation via `requirements.txt`**: |
| 22 | +### Environment Variables |
20 | 23 |
|
21 | | -```shell |
22 | | -$ git clone https://github.com/hackersandslackers/flask-sqlalchemy-tutorial.git |
23 | | -$ cd flask-sqlalchemy-tutorial |
24 | | -$ python3 -m venv myenv |
25 | | -$ source myenv/bin/activate |
26 | | -$ pip3 install -r requirements.txt |
27 | | -$ flask run |
28 | | -``` |
| 24 | +Replace the values in **.env.example** with your values and rename this file to **.env**: |
29 | 25 |
|
30 | | -**Installation via [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/)**: |
| 26 | +* `FLASK_APP`: Entry point of your application; should be `wsgi.py`. |
| 27 | +* `FLASK_ENV`: The environment in which to run your application; either `development` or `production`. |
| 28 | +* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data. |
| 29 | +* `SQLALCHEMY_DATABASE_URI`: SQLAlchemy connection URI to a SQL database. |
31 | 30 |
|
32 | | -```shell |
33 | | -$ git clone https://github.com/hackersandslackers/flask-sqlalchemy-tutorial.git |
34 | | -$ cd flask-sqlalchemy-tutorial |
35 | | -$ pipenv shell |
36 | | -$ pipenv update |
37 | | -$ flask run |
38 | | -``` |
| 31 | +*Remember never to commit secrets saved in .env files to Github.* |
39 | 32 |
|
40 | | -**Installation via [Poetry](https://python-poetry.org/)**: |
| 33 | +### Installation |
| 34 | + |
| 35 | +Get up and running with `make deploy`: |
41 | 36 |
|
42 | 37 | ```shell |
43 | 38 | $ git clone https://github.com/hackersandslackers/flask-sqlalchemy-tutorial.git |
44 | 39 | $ cd flask-sqlalchemy-tutorial |
45 | | -$ poetry shell |
46 | | -$ poetry update |
47 | | -$ poetry run |
48 | | -``` |
49 | | - |
50 | | -## Usage |
51 | | - |
52 | | -Replace the values in **.env.example** with your values and rename this file to **.env**: |
53 | | - |
54 | | -* `FLASK_APP`: Entry point of your application (should be `wsgi.py`). |
55 | | -* `FLASK_ENV`: The environment to run your app in (either `development` or `production`). |
56 | | -* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data. |
57 | | -* `SQLALCHEMY_DATABASE_URI`: SQLAlchemy connection URI to a SQL database. |
58 | | - |
59 | | -*Remember never to commit secrets saved in .env files to Github.* |
| 40 | +$ make deploy |
| 41 | +``` |
60 | 42 |
|
61 | 43 | ----- |
62 | 44 |
|
63 | | -**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content. |
| 45 | +**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content. |
0 commit comments