MCPcopy Create free account
hub / github.com/AgriQuantAI/AgriQuant-AI / demo_database_storage

Function demo_database_storage

demo.py:170–205  ·  view source on GitHub ↗

Demo: Store data in database

(forecast, prediction)

Source from the content-addressed store, hash-verified

168
169
170def 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
208def demo_performance_tracking():

Callers 1

demo_complete_workflowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected