Demo: Store data in database
(forecast, prediction)
| 168 | |
| 169 | |
| 170 | def demo_database_storage(forecast, prediction): |
| 171 | """Demo: Store data in database""" |
| 172 | |
| 173 | print("\n" + "="*80) |
| 174 | print("DEMO 3: DATABASE STORAGE") |
| 175 | print("="*80) |
| 176 | |
| 177 | print("\nNote: This demo requires PostgreSQL to be running.") |
| 178 | print("Database configuration: config.DATABASE_URL") |
| 179 | print("\nTo actually run database operations:") |
| 180 | print(" 1. Install PostgreSQL") |
| 181 | print(" 2. Create database: createdb agriquant") |
| 182 | print(" 3. Set DATABASE_URL in .env file") |
| 183 | print(" 4. Run: python -c 'from database import *; db=AgriQuant AIDatabase(); db.connect(); db.create_tables()'") |
| 184 | |
| 185 | print("\n--- Database Schema ---") |
| 186 | print("Tables that would be created:") |
| 187 | print(" • weather_forecasts - NOAA forecast data") |
| 188 | print(" • ai_predictions - Claude predictions") |
| 189 | print(" • historical_events - 40 years of verified events") |
| 190 | print(" • usda_reports - USDA crop damage reports") |
| 191 | print(" • satellite_imagery - Planet Labs / Sentinel-2 data") |
| 192 | print(" • market_prices - CME agricultural commodity futures") |
| 193 | print(" • performance_metrics - Accuracy tracking") |
| 194 | |
| 195 | print("\n--- Example Database Operations ---") |
| 196 | print("Forecast would be stored with ID:") |
| 197 | print(f" County: {forecast.get('county', 'N/A')}") |
| 198 | print(f" Freeze Risk: {forecast.get('freeze_risk', {}).get('risk', 'N/A')}") |
| 199 | |
| 200 | if prediction: |
| 201 | print("\nPrediction would be stored with:") |
| 202 | print(f" ID: {prediction.get('prediction_id', 'N/A')}") |
| 203 | print(f" Expected Damage: {prediction.get('expected_crop_damage_pct', 0)*100:.1f}%") |
| 204 | print(f" Confidence: {prediction.get('confidence_score', 0)*100:.0f}%") |
| 205 | print(f" Verified: False (pending USDA report)") |
| 206 | |
| 207 | |
| 208 | def demo_performance_tracking(): |
no outgoing calls
no test coverage detected