|
1 | 1 | # Flask-SQLAlchemy Tutorial |
2 | 2 |
|
3 | 3 |  |
4 | | - |
| 4 | + |
5 | 5 |  |
6 | 6 |  |
7 | 7 | [](https://github.com/hackersandslackers/flask-sqlalchemy-tutorial/issues) |
|
12 | 12 |
|
13 | 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/). |
14 | 14 |
|
15 | | -## Getting Started |
| 15 | +## Installation |
16 | 16 |
|
17 | | -Installation is recommended with Pipenv: |
| 17 | +**Installation via `requirements.txt`**: |
18 | 18 |
|
19 | 19 | ```shell |
20 | 20 | $ git clone https://github.com/hackersandslackers/flask-sqlalchemy-tutorial.git |
21 | 21 | $ cd flask-sqlalchemy-tutorial |
22 | | -$ pipenv shell |
23 | | -$ pipenv update |
| 22 | +$ python3 -m venv myenv |
| 23 | +$ source myenv/bin/activate |
| 24 | +$ pip3 install -r requirements.txt |
24 | 25 | $ flask run |
25 | 26 | ``` |
26 | 27 |
|
27 | | -Alternatively, try installing via `requirements.txt`: |
| 28 | +**Installation via [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/)**: |
28 | 29 |
|
29 | 30 | ```shell |
30 | 31 | $ git clone https://github.com/hackersandslackers/flask-sqlalchemy-tutorial.git |
31 | | -$ cd flasksession-tutorial |
32 | | -$ python3 -m pip install requirements.txt |
| 32 | +$ cd flask-sqlalchemy-tutorial |
| 33 | +$ pipenv shell |
| 34 | +$ pipenv update |
33 | 35 | $ flask run |
34 | 36 | ``` |
| 37 | + |
| 38 | +## Configuration |
| 39 | + |
| 40 | +Configuration is handled by creating a **.env** file. This should contain the following variables (replace the values with your own): |
| 41 | + |
| 42 | +```.env |
| 43 | +FLASK_ENV="production" |
| 44 | +SECRET_KEY="YOURSECRETKEY" |
| 45 | +SQLALCHEMY_DATABASE_URI="mysql+pymysql://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE_NAME]" |
| 46 | +``` |
35 | 47 | ----- |
36 | 48 |
|
37 | 49 | **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