Sample databases for testing (MySQL). Replace DinisMiranda in the badges with your GitHub org or username.
BD_exemplos/
├── config.toml.example # Config template (copy to config.toml)
├── pyproject.toml # Poetry project (poetry install)
├── bd_exemplos/ # Python package
│ ├── config.py # Config loader
│ ├── db.py # Shared MySQL connection
│ └── scripts/ # Seed scripts (run with python -m)
│ ├── seed_loja.py # Shop: suppliers, products, clients, orders
│ ├── seed_biblioteca.py # Library: authors, books, readers, loans
│ ├── seed_cinema.py # Cinema: films, rooms, sessions, tickets
│ └── seed_clinica.py # Clinic: doctors, patients, appointments
├── tests/ # Tests (pytest)
│ ├── test_config.py # load_config
│ └── test_builders.py # build_static_entities, build_autores, etc.
├── requirements.txt
├── README.md
└── LICENSE
The config.toml file (with your MySQL password) is not in the repository for security. Use the template:
- Copy the example to create your config file:
cp config.toml.example config.toml
- Edit
config.tomland set:password— your MySQL password (e.g. MySQL Workbench). Can be empty if your local server has no password.database— database name (e.g.BD_TESTEorBD_TESTE2).- Optionally adjust
host,port,user.
If you don't have Poetry installed yet:
curl -sSL https://install.python-poetry.org | python3 -Restart your terminal (or run source ~/.zshrc) so the poetry command is available.
-
Install dependencies (from the repository root):
poetry install
-
Run the seeds (
config.tomlmust be in the repo root):# Shop (suppliers, products, clients, orders) poetry run python -m bd_exemplos.scripts.seed_loja # Library (authors, books, readers, loans) poetry run python -m bd_exemplos.scripts.seed_biblioteca # Cinema (films, rooms, sessions, tickets) poetry run python -m bd_exemplos.scripts.seed_cinema # Clinic (doctors, patients, appointments) poetry run python -m bd_exemplos.scripts.seed_clinica
With poetry install, Poetry creates the virtual environment and installs the package; no need for PYTHONPATH.
poetry run pytest tests/ -v
poetry run pytest tests/ --cov=bd_exemplos --cov-report=term-missing- Lint:
poetry run ruff check bd_exemplos testsandpoetry run ruff format bd_exemplos tests --check - Fix style:
poetry run ruff check bd_exemplos tests --fixandpoetry run ruff format bd_exemplos tests - See CONTRIBUTING.md for full setup and PR process.
- Python ^3.9
- Managed in
pyproject.toml:toml,mysql-connector-python
Install: poetry install. To generate requirements.txt (e.g. for CI/Docker): poetry export -f requirements.txt --without-hashes.