CoolFace
Apppublic

simeonubi/Agri-Doctor-AI

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
database_setup.py30 linesDownload Raw Back to root
1import sqlite32 3def setup_database():4    # 1. Connect to the SQLite database (creates the file if it doesn't exist)5    conn = sqlite3.connect('farm_telemetry.db')6    cursor = conn.cursor()7 8    # 2. Write the SQL to create the table9    create_table_query = """10   CREATE TABLE IF NOT EXISTS diagnostics_log (11    log_id TEXT PRIMARY KEY,12    image_hash TEXT NOT NULL,  -- NEW COLUMN ADDED HERE13    timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,14    predicted_class TEXT NOT NULL,15    model_confidence REAL NOT NULL,16    ai_advice_text TEXT,17    user_rating INTEGER,18    coarse_location TEXT19);20    """21    22    # 3. Execute and save23    cursor.execute(create_table_query)24    conn.commit()25    conn.close()26    27    print("✅ Database and table successfully created!")28 29if __name__ == "__main__":30    setup_database()