Skip to content

Commit 27467d7

Browse files
committed
feat: Add configuration files and database requirements
Created comprehensive configuration framework: Configuration files (config/): - data_sources.yaml: Data source settings, retry/rate limiting config - leagues.yaml: League mappings to soccerdata library IDs - logging.yaml: Logging configuration (level, directory, handlers) Environment configuration: - .env.example: Database connection template and extraction settings Dependencies: - requirements-database.txt: Additional dependencies for database (psycopg2-binary, python-dotenv, PyYAML) All configuration is centralized and environment-based for easy deployment.
1 parent fa99bfa commit 27467d7

File tree

5 files changed

+160
-0
lines changed

5 files changed

+160
-0
lines changed

.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Database Configuration
2+
# Copy this file to .env and fill in your actual credentials
3+
4+
# PostgreSQL Database Connection
5+
DB_HOST=localhost
6+
DB_PORT=5432
7+
DB_NAME=football_stats
8+
DB_USER=postgres
9+
DB_PASSWORD=your_password_here
10+
11+
# Historical Loader Configuration
12+
START_SEASON=2021
13+
END_SEASON=2425
14+
BATCH_SIZE=100
15+
PARALLEL_WORKERS=1
16+
SKIP_COMPLETED=true

config/data_sources.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Data Sources Configuration
2+
# Defines which data sources are enabled and extraction settings
3+
4+
sources:
5+
fbref:
6+
enabled: true
7+
priority: 1
8+
description: "Football Reference (Opta data) - Most comprehensive statistics"
9+
tables: 44
10+
11+
fotmob:
12+
enabled: true
13+
priority: 2
14+
description: "FotMob - League tables and match statistics"
15+
tables: 11
16+
17+
understat:
18+
enabled: true
19+
priority: 3
20+
description: "Understat - Advanced xG metrics and shot coordinates"
21+
tables: 7
22+
23+
whoscored:
24+
enabled: true
25+
priority: 4
26+
description: "WhoScored - Detailed Opta event stream"
27+
tables: 4
28+
29+
sofascore:
30+
enabled: true
31+
priority: 5
32+
description: "Sofascore - Standings and schedules"
33+
tables: 4
34+
35+
espn:
36+
enabled: true
37+
priority: 6
38+
description: "ESPN - Schedules, matchsheets, and lineups"
39+
tables: 3
40+
41+
clubelo:
42+
enabled: true
43+
priority: 7
44+
description: "ClubElo - ELO ratings"
45+
tables: 2
46+
47+
matchhistory:
48+
enabled: true
49+
priority: 8
50+
description: "MatchHistory - Betting odds from 13+ bookmakers"
51+
tables: 1
52+
53+
sofifa:
54+
enabled: true
55+
priority: 9
56+
description: "SoFIFA - EA Sports FC player/team ratings"
57+
tables: 6
58+
59+
# Extraction settings
60+
extraction:
61+
# Retry configuration for failed API calls
62+
retry:
63+
max_attempts: 3
64+
initial_delay: 2 # seconds
65+
max_delay: 60 # seconds
66+
exponential_base: 2
67+
68+
# Rate limiting to avoid overloading APIs
69+
rate_limiting:
70+
enabled: true
71+
requests_per_minute: 20
72+
delay_between_requests: 3 # seconds
73+
74+
# Batch processing
75+
batch:
76+
size: 100 # records per batch for database insertion
77+
78+
# Error handling
79+
error_handling:
80+
continue_on_error: true # Continue with next source if one fails
81+
max_consecutive_failures: 5 # Stop after this many consecutive failures

config/leagues.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Leagues Configuration
2+
# Maps standardized league names to soccerdata library IDs
3+
4+
leagues:
5+
- name: "ENG-Premier League"
6+
soccerdata_id: "ENG-Premier League"
7+
country: "England"
8+
tier: 1
9+
enabled: true
10+
11+
- name: "ESP-La Liga"
12+
soccerdata_id: "ESP-La Liga"
13+
country: "Spain"
14+
tier: 1
15+
enabled: true
16+
17+
- name: "GER-Bundesliga"
18+
soccerdata_id: "GER-Bundesliga"
19+
country: "Germany"
20+
tier: 1
21+
enabled: true
22+
23+
- name: "ITA-Serie A"
24+
soccerdata_id: "ITA-Serie A"
25+
country: "Italy"
26+
tier: 1
27+
enabled: true
28+
29+
- name: "FRA-Ligue 1"
30+
soccerdata_id: "FRA-Ligue 1"
31+
country: "France"
32+
tier: 1
33+
enabled: true

config/logging.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Logging Configuration
2+
3+
# Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
4+
log_level: INFO
5+
6+
# Directory for log files
7+
log_dir: logs
8+
9+
# Enable file logging
10+
log_to_file: true
11+
12+
# Enable console logging
13+
log_to_console: true
14+
15+
# Log rotation (optional - implement in future)
16+
rotation:
17+
enabled: false
18+
max_bytes: 10485760 # 10 MB
19+
backup_count: 5

requirements-database.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Additional Requirements for Football Statistics Database
2+
3+
# Database
4+
psycopg2-binary>=2.9.0
5+
6+
# Configuration
7+
python-dotenv>=1.0.0
8+
PyYAML>=6.0
9+
10+
# Note: This extends the main requirements.txt file
11+
# Install both with: pip install -r requirements.txt -r requirements-database.txt

0 commit comments

Comments
 (0)