help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
weather-chatbot
/
scripts
RSK World
weather-chatbot
Weather Chatbot - Python + Flask + OpenWeatherMap + OpenAI + Weather Forecast + Weather Alerts + Natural Language Processing
scripts
  • init_db.py1.6 KB
init_db.py
scripts/init_db.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Initialize Database Script
==========================

Author: RSK World (https://rskworld.in)
Year: 2026

Description: Script to initialize the weather chatbot database
"""

import os
import sys

# Add parent directory to path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from utils.database import WeatherDatabase

def main():
    """Initialize the database."""
    print("Initializing Weather Chatbot Database...")
    print("=" * 60)
    
    db_path = os.getenv('DATABASE_URL', 'weather_chatbot.db')
    if db_path.startswith('sqlite:///'):
        db_path = db_path.replace('sqlite:///', '')
    
    print(f"Database path: {db_path}")
    
    try:
        db = WeatherDatabase(db_path=db_path)
        print("✓ Database initialized successfully")
        
        # Get database stats
        stats = db.get_database_stats()
        
        print("\nDatabase Statistics:")
        print(f"  • Users: {stats.get('users_count', 0)}")
        print(f"  • Weather History Records: {stats.get('weather_history_count', 0)}")
        print(f"  • User Queries: {stats.get('user_queries_count', 0)}")
        print(f"  • Weather Alerts: {stats.get('weather_alerts_count', 0)}")
        print(f"  • Favorite Cities: {stats.get('user_favorites_count', 0)}")
        
        print("\n" + "=" * 60)
        print("Database setup complete!")
        print("=" * 60)
        
    except Exception as e:
        print(f"❌ Error initializing database: {e}")
        sys.exit(1)

if __name__ == '__main__':
    main()
55 lines•1.6 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer