Skip to content

Commit dd873a0

Browse files
committed
Organize repo by series chapter.
1 parent 776b392 commit dd873a0

File tree

20 files changed

+198
-72
lines changed

20 files changed

+198
-72
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
SQLALCHEMY_DATABASE_URI=mysql+pymysql://myuser:[email protected]:1234/mydatabase
2+
SQLALCHEMY_DATABASE_PEM="-----BEGIN CERTIFICATE-----\nghdfigfjvgkjdfvfjkhcvdfjhvfghjbfdvfjshdvjghvfgjvcfjdcvckdjh\n-----END CERTIFICATE-----\n"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ all help:
3131

3232
.PHONY: run
3333
run: env
34-
flask run
34+
python main.py
3535

3636

3737
.PHONY: deploy

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010

1111
![SQLAlchemy Tutorial](https://github.com/hackersandslackers/sqlalchemy-tutorial/blob/master/.github/[email protected]?raw=true)
1212

13-
**Tutorial**: https://hackersandslackers.com/python-database-management-sqlalchemy/
13+
This repository contains the source code for a four-part tutorial series on SQLAlchemy:
14+
15+
1. [Databases in Python Made Easy with SQLAlchemy](https://hackersandslackers.com/python-database-management-sqlalchemy)
16+
2. [Implement an ORM with SQLAlchemy](https://hackersandslackers.com/implement-sqlalchemy-orm)
17+
3. [Relationships in SQLAlchemy Data Models](https://hackersandslackers.com/sqlalchemy-data-models)
18+
4. [Constructing Database Queries with SQLAlchemy](https://hackersandslackers.com/database-queries-sqlalchemy-orm)
1419

1520
# Getting Started
1621

@@ -22,6 +27,7 @@ Replace the values in **.env.example** with your values and rename this file to
2227

2328

2429
* `SQLALCHEMY_DATABASE_URI`: Connection URI of a SQL database.
30+
* `SQLALCHEMY_DATABASE_PEM` _(Optional)_: PEM key for databases requiring an SSL connection.
2531

2632
*Remember never to commit secrets saved in .env files to Github.*
2733

config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Database config."""
2-
from datetime import datetime
32
from os import environ, path
43

54
from dotenv import load_dotenv
@@ -8,7 +7,6 @@
87
basedir = path.abspath(path.dirname(__file__))
98
load_dotenv(path.join(basedir, ".env"))
109

11-
10+
# Database connection variables
1211
SQLALCHEMY_DATABASE_URI = environ.get("SQLALCHEMY_DATABASE_URI")
1312
SQLALCHEMY_DATABASE_PEM = environ.get("SQLALCHEMY_DATABASE_PEM")
14-
TIME_NOW = datetime.now()
File renamed without changes.

sqlalchemy_tutorial/database/connect.py renamed to database/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Create database connection."""
1+
"""Create SQLAlchemy engine and session objects."""
22
from sqlalchemy import create_engine
33
from sqlalchemy.orm import sessionmaker
44

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Script entry point."""
12
from sqlalchemy_tutorial import init_script
23

34
if __name__ == "__main__":

poetry.lock

Lines changed: 36 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ python = "^3.8"
2222
sqlalchemy = "*"
2323
pymysql = "*"
2424
python-dotenv = "*"
25+
loguru = "^0.5.3"
2526

2627
[tool.poetry.dev-dependencies]
2728
pytest = "*"

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
colorama==0.4.4; python_version >= "3.5" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.5" and python_full_version >= "3.5.0"
2+
loguru==0.5.3; python_version >= "3.5"
13
pymysql==1.0.2; python_version >= "3.6"
24
python-dotenv==0.15.0
35
sqlalchemy==1.3.22; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
6+
win32-setctime==1.0.3; sys_platform == "win32" and python_version >= "3.5"

0 commit comments

Comments
 (0)